]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix parsing of SMB3.1.1 POSIX create context
authorPaulo Alcantara <pc@manguebit.com>
Sat, 10 Feb 2024 20:14:44 +0000 (01:44 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:16:43 +0000 (13:16 +0100)
[ Upstream commit 76025cc2285d9ede3d717fe4305d66f8be2d9346 ]

The data offset for the SMB3.1.1 POSIX create context will always be
8-byte aligned so having the check 'noff + nlen >= doff' in
smb2_parse_contexts() is wrong as it will lead to -EINVAL because noff
+ nlen == doff.

Fix the sanity check to correctly handle aligned create context data.

Fixes: af1689a9b770 ("smb: client: fix potential OOBs in smb2_parse_contexts()")
Signed-off-by: Paulo Alcantara <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
[Guru:smb2_parse_contexts()  is present in file smb2ops.c,
smb2ops.c file location is changed, modified patch accordingly.]
Signed-off-by: Guruswamy Basavaiah <guruswamy.basavaiah@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/smb2pdu.c

index 4fc9ee4c5fed61d250f7cadc773d1fa1ea6a18e1..aa3211d8cce3bd7e0892e6b657e53b9c4a58e645 100644 (file)
@@ -2030,7 +2030,7 @@ int smb2_parse_contexts(struct TCP_Server_Info *server,
 
                noff = le16_to_cpu(cc->NameOffset);
                nlen = le16_to_cpu(cc->NameLength);
-               if (noff + nlen >= doff)
+               if (noff + nlen > doff)
                        return -EINVAL;
 
                name = (char *)cc + noff;