]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ksmbd: Fix an error handling path in 'smb2_sess_setup()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 7 Nov 2021 15:22:57 +0000 (16:22 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:03 +0000 (09:49 +0100)
BugLink: https://bugs.launchpad.net/bugs/1953370
commit f8fbfd85f5c95fff477a7c19f576725945891d0c upstream.

All the error handling paths of 'smb2_sess_setup()' end to 'out_err'.

All but the new error handling path added by the commit given in the Fixes
tag below.

Fix this error handling path and branch to 'out_err' as well.

Fixes: 0d994cd482ee ("ksmbd: add buffer validation in session setup")
Cc: stable@vger.kernel.org # v5.15
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
fs/ksmbd/smb2pdu.c

index 691c861e41a2e1c62698b2c8ea5caa6138935b95..ad0ea5d36f2eebcdb38ff65932f7cef69c2d8754 100644 (file)
@@ -1700,8 +1700,10 @@ int smb2_sess_setup(struct ksmbd_work *work)
        negblob_off = le16_to_cpu(req->SecurityBufferOffset);
        negblob_len = le16_to_cpu(req->SecurityBufferLength);
        if (negblob_off < (offsetof(struct smb2_sess_setup_req, Buffer) - 4) ||
-           negblob_len < offsetof(struct negotiate_message, NegotiateFlags))
-               return -EINVAL;
+           negblob_len < offsetof(struct negotiate_message, NegotiateFlags)) {
+               rc = -EINVAL;
+               goto out_err;
+       }
 
        negblob = (struct negotiate_message *)((char *)&req->hdr.ProtocolId +
                        negblob_off);