[PATCH] smb: fix invalid username check in smb3_fs_context_parse_param()

Steve French smfrench at gmail.com
Tue Nov 11 16:03:47 UTC 2025


tentatively applied to for-next pending review and testing

On Tue, Nov 11, 2025 at 1:19 AM Yiqi Sun <sunyiqixm at gmail.com> wrote:
>
> 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 at gmail.com>
> ---
>  fs/smb/client/fs_context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index 59ccc2229ab3..d2cf1f60416a 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1470,7 +1470,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;
> --
> 2.34.1
>
>


-- 
Thanks,

Steve



More information about the samba-technical mailing list