]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: Use struct_size() helper in ksmbd_negotiate_smb_dialect()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Sun, 31 Dec 2023 07:12:49 +0000 (16:12 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 14:18:31 +0000 (15:18 +0100)
[ Upstream commit 5211cc8727ed9701b04976ab47602955e5641bda ]

Prefer struct_size() over open-coded versions.

Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/server/smb_common.c

index 62c33d3357fe1aa711bdc02dec2aa7fcdeb5c77d..b6f414a2404b108e8a3211d5f96b03c00389e90c 100644 (file)
@@ -266,7 +266,7 @@ static int ksmbd_negotiate_smb_dialect(void *buf)
                if (smb2_neg_size > smb_buf_length)
                        goto err_out;
 
-               if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) >
+               if (struct_size(req, Dialects, le16_to_cpu(req->DialectCount)) >
                    smb_buf_length)
                        goto err_out;