]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: fix invalid username check in smb3_fs_context_parse_param()
authorYiqi Sun <sunyiqixm@gmail.com>
Tue, 11 Nov 2025 07:05:39 +0000 (15:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Dec 2025 17:37:20 +0000 (18:37 +0100)
[ Upstream commit ed6612165b74f09db00ef0abaf9831895ab28b7f ]

Since the maximum return value of strnlen(..., CIFS_MAX_USERNAME_LEN)
is CIFS_MAX_USERNAME_LEN, length check in smb3_fs_context_parse_param()
is always FALSE and invalid.

Fix the comparison in if statement.

Signed-off-by: Yiqi Sun <sunyiqixm@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/fs_context.c

index 9a4492106c25f8e1a50b6056c3216129a8541bca..17133adfe798b07a3c732a9c4918d56ceb00ce47 100644 (file)
@@ -1415,7 +1415,7 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
                        break;
                }
 
-               if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) >
+               if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) ==
                    CIFS_MAX_USERNAME_LEN) {
                        pr_warn("username too long\n");
                        goto cifs_parse_mount_err;