]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ksmbd: use memcmp() to compare ClientGUIDs
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 20 Jul 2026 01:32:01 +0000 (10:32 +0900)
committerSteve French <stfrench@microsoft.com>
Thu, 30 Jul 2026 23:45:57 +0000 (18:45 -0500)
ClientGUID is a fixed-size binary value and can contain embedded NUL
bytes. strncmp() stops comparing at the first NUL byte, so different
ClientGUID values can incorrectly be treated as equal.

Use memcmp() in SMB3 multichannel session binding and
FSCTL_VALIDATE_NEGOTIATE_INFO to compare all SMB2_CLIENT_GUID_SIZE
bytes.

Fixes: f5a544e3bab7 ("ksmbd: add support for SMB3 multichannel")
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Reported-by: Samu <nomomentomori@gmail.com>
Suggested-by: Samu <nomomentomori@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb2pdu.c

index 404a4203f7da5fe502b4b748e13c3000e34f84aa..76f63f9adc7254dcb1df2236b32e00833edc21c8 100644 (file)
@@ -1969,7 +1969,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
                        goto out_err;
                }
 
-               if (strncmp(conn->ClientGUID, sess->ClientGUID,
+               if (memcmp(conn->ClientGUID, sess->ClientGUID,
                            SMB2_CLIENT_GUID_SIZE)) {
                        rc = -ENOENT;
                        goto out_err;
@@ -8690,7 +8690,7 @@ static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn,
                goto err_out;
        }
 
-       if (strncmp(neg_req->Guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE)) {
+       if (memcmp(neg_req->Guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE)) {
                ret = -EINVAL;
                goto err_out;
        }