mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication
@ 2026-12-04 15:14 Piyus Kedia
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Piyus Kedia @ 2026-12-04 15:14 UTC (permalink / raw)
  To: Namjae Jeon, linux-cifs
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, linux-kernel,
	Kapil Vaswani

Hi,

ksmbd_compare_user() compares two users' passkeys over the length of
the first one only:

  fs/smb/server/mgmt/user_config.c:108
      if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))

Each passkey is allocated by ksmbd_alloc_user() at the hash_sz of its
own login response from the user-space daemon:

  fs/smb/server/mgmt/user_config.c:59
      user->passkey_sz = resp->hash_sz;
      user->passkey = kmalloc(resp->hash_sz, KSMBD_DEFAULT_GFP);

so nothing makes u2's passkey as long as u1's.  ntlm_authenticate()
calls it when a client re-authenticates a session, with u1 the
session's user and u2 the user just logged in for this request
(fs/smb/server/smb2pdu.c:2344; the expired-session branch at 2355 makes
the same call).  When the second login response carried a shorter
hash, memcmp() reads past the end of the new passkey:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x51/0xd0 lib/string.c:665
  Read of size 8 at addr ffff888040fc1dc0 by task kworker/2:2/3253
  Workqueue: ksmbd-io handle_ksmbd_work
   memcmp+0x51/0xd0 lib/string.c:665
   bcmp+0x36/0x60 lib/string.c:697
   ksmbd_compare_user+0x97/0xd0 fs/smb/server/mgmt/user_config.c:108
   ntlm_authenticate+0x37e/0x9a0 fs/smb/server/smb2pdu.c:2344
   smb2_sess_setup+0x155e/0x1730 fs/smb/server/smb2pdu.c:2774
   __process_request+0x28f/0x4e0 fs/smb/server/server.c:163
   __handle_ksmbd_work+0x440/0xbc0 fs/smb/server/server.c:296
   handle_ksmbd_work+0x5f/0xa0 fs/smb/server/server.c:387

  Allocated by task 3253:
   __kmalloc_noprof+0x2ba/0x620 mm/slub.c:5562
   ksmbd_alloc_user+0x13b/0x360 fs/smb/server/mgmt/user_config.c:60
   ksmbd_login_user+0xb2/0x100 fs/smb/server/mgmt/user_config.c:28
   session_user+0x1ba/0x240 fs/smb/server/smb2pdu.c:2294
   ntlm_authenticate+0x212/0x9a0 fs/smb/server/smb2pdu.c:2328

  The buggy address belongs to the object at ffff888040fc1dc0
   which belongs to the cache kmalloc-8 of size 8
  The buggy address is located 0 bytes inside of
   allocated 1-byte region [ffff888040fc1dc0, ffff888040fc1dc1)

How it is reached.  The reproducer registers itself as the ksmbd
daemon over the ksmbd generic netlink family (KSMBD_EVENT_STARTING_UP),
then connects to the server over TCP as an SMB 3.1.1 client and does
an NTLMSSP session setup as user "u" twice on the same SessionId.  Its
daemon answers the two LOGIN_REQUESTs for "u" with hash_sz 18 and then
1, with KSMBD_USER_FLAG_GUEST_ACCOUNT set so the NTLMv2 check is
skipped and the first setup leaves the session valid.  The second
setup then compares the session's 18-byte passkey with the new 1-byte
one.  It has reproduced every time we ran it: five runs on two
kernels, one of them unprivileged (below).

Impact - who can trigger it:

  - The two lengths come from the daemon's login responses; an SMB
    client controls only the account name and the NTLMSSP blobs.  So
    the trigger is a daemon that reports a different hash size for the
    same account on a later login.  We have not found a way to make
    ksmbd.mountd do that from the network, but we have not audited
    ksmbd-tools either.  This is the trust boundary of 7405d0ba2943
    ("ksmbd: fix slab-out-of-bounds read in ksmbd_alloc_user()"),
    which bounds hash_sz from above; nothing bounds it from below
    against the session's earlier login.

  - With CONFIG_SMB_SERVER_CHECK_CAP_NET_ADMIN=y, the default,
    handle_startup_event() and handle_generic_event() require
    CAP_NET_ADMIN, checked by netlink_capable() against the initial
    user namespace.  An unprivileged user cannot register as the
    daemon or send it a login response, from a user namespace either,
    so on a default build this needs root (or a compromised or buggy
    daemon).

  - With that option disabled, neither handler checks anything.  We
    ran the same reproducer as uid 65534 with every capability dropped
    (CapEff and CapBnd 0), on a 7.4.0-rc5 build with the option off
    and no daemon running: it registered as the daemon and triggered
    the same KASAN report.  So on such a build any local user can
    trigger it while ksmbd.mountd is not running.  While it is
    running, handle_startup_event() refuses a second daemon, but
    handle_generic_event() matches a response to its request only by
    type and by a handle from an IDA, not by sender, so a forged
    LOGIN_RESPONSE from another process would be accepted as well; we
    have not tried that.

  - What the read does: it reads up to passkey_sz bytes from a
    shorter allocation, here 17 bytes past a 1-byte kmalloc-8 object.
    Nothing read is returned to the client; the bytes only decide
    whether the re-authentication is accepted or fails with
    -EKEYREJECTED.

Seen on 7.4.0-rc5 and REPRODUCED ON ksmbd-for-next (d70570cf8003,
2026-12-04) with KASAN.  On 7.4-rc5 the read came from the
valid-session call (smb2pdu.c:2344 there); on ksmbd-for-next the same
program reached it through the expired-session call, smb2pdu.c:2402:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0
  Read of size 8 at addr ffff88805834a120 by task kworker/1:0/26
   memcmp+0x8b/0xb0 lib/string.c:665
   ksmbd_compare_user+0x82/0xb0 fs/smb/server/mgmt/user_config.c:108
   smb2_sess_setup+0x222d/0x3610 fs/smb/server/smb2pdu.c:2402

ksmbd_compare_user() and both calls are the same in mainline
(007722b8211f, 2026-12-03).  The comparison has been this way since it
was added in a58b45a4dbfd ("ksmbd: set RSS capable in
FSCTL_QUERY_NETWORK_INTERFACE_INFO"), so v5.17 and later.

A patch follows in reply to this mail.  Users whose passkeys differ in
length are not the same user, so it compares the lengths before the
bytes.  On ksmbd-for-next, same config and image before and after,
only that change between the two builds:

  without the patch   KASAN slab-out-of-bounds read, as above
  with the patch      the same program runs to the end and the
                      re-authentication is rejected (STATUS_ACCESS_DENIED,
                      as before), no report, twice

This was found by AI-driven fuzzing built on top of syzkaller; its
analysis was then checked by hand against the code and every claim
above was reproduced.  The reproducer is fuzzer-generated, runs the
daemon and the client in one program over loopback, and we are happy
to send it on request.

Kapil Vaswani
Piyus Kedia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user()
  2026-12-04 15:14 [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
@ 2026-12-04 15:14 ` Piyus Kedia
  2026-12-04 15:14 ` [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
  2 siblings, 0 replies; 6+ messages in thread
From: Piyus Kedia @ 2026-12-04 15:14 UTC (permalink / raw)
  To: Namjae Jeon, linux-cifs
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, linux-kernel,
	Kapil Vaswani

ksmbd_compare_user() compares the passkeys of two users over the
length of the first one:

	if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))

Each passkey is allocated by ksmbd_alloc_user() at the hash_sz of its
own login response from the user-space daemon, so the second one can
be shorter.  ntlm_authenticate() makes this comparison when a session
is re-authenticated, valid or expired, between the session's user and
the user just logged in, and when the later login response carried a
smaller hash_sz, memcmp() reads past the end of the new passkey:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0
  Read of size 8 at addr ffff88805834a120 by task kworker/1:0/26
  Workqueue: ksmbd-io handle_ksmbd_work
   memcmp+0x8b/0xb0 lib/string.c:665
   ksmbd_compare_user+0x82/0xb0 fs/smb/server/mgmt/user_config.c:108
   smb2_sess_setup+0x222d/0x3610 fs/smb/server/smb2pdu.c:2402
   handle_ksmbd_work+0x4d7/0x13d0 fs/smb/server/server.c:223
   process_one_work+0x6f7/0x11a0 kernel/workqueue.c:3497
   worker_thread+0x417/0x7b0 kernel/workqueue.c:3580

  Allocated by task 26:
   __kmalloc_noprof+0x357/0x810 mm/slub.c:5556
   ksmbd_alloc_user+0x122/0x2f0 fs/smb/server/mgmt/user_config.c:60
   ksmbd_login_user+0x7d/0xd0 fs/smb/server/mgmt/user_config.c:28
   smb2_sess_setup+0x2172/0x3610 fs/smb/server/smb2pdu.c:2375

  The buggy address belongs to the object at ffff88805834a120
   which belongs to the cache kmalloc-8 of size 8
  The buggy address is located 0 bytes inside of
   allocated 1-byte region [ffff88805834a120, ffff88805834a121)

Users whose passkeys differ in length are not the same user, so
compare the lengths before the bytes.

The lengths come from the daemon's login responses, so this takes a
daemon that reports a different hash size for the same account on a
later login.  Like the upper bound on hash_sz in ksmbd_alloc_user(),
the check keeps such a response from becoming an out-of-bounds read.

We found this with a syzkaller-based fuzzing harness driven by an AI tool.

Fixes: a58b45a4dbfd ("ksmbd: set RSS capable in FSCTL_QUERY_NETWORK_INTERFACE_INFO")
Closes: https://lore.kernel.org/linux-cifs/ksmbd-compare-user-passkey.20261204@iiitd.ac.in/
Cc: stable@vger.kernel.org
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
---
Tested on ksmbd-for-next (d70570cf8003) with KASAN, the same config and
image before and after, only this change between the two builds.  The
reproducer plays the user-space daemon over the ksmbd genetlink family,
answers the two LOGIN_REQUESTs for one account with hash_sz 18 and then
1, and re-authenticates an NTLMSSP session over TCP:

  before   KASAN slab-out-of-bounds read in memcmp, from the call at
           smb2pdu.c:2402 (on 7.4-rc5 the same read came from the
           valid-session call, then at smb2pdu.c:2344)
  after    the same program runs to the end, the re-authentication is
           rejected (STATUS_ACCESS_DENIED, as before), no report, twice

 fs/smb/server/mgmt/user_config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/mgmt/user_config.c b/fs/smb/server/mgmt/user_config.c
index 5efc3d7455b9..2bebf1ca0d80 100644
--- a/fs/smb/server/mgmt/user_config.c
+++ b/fs/smb/server/mgmt/user_config.c
@@ -105,7 +105,8 @@ bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2)
 {
 	if (strcmp(u1->name, u2->name))
 		return false;
-	if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))
+	if (u1->passkey_sz != u2->passkey_sz ||
+	    memcmp(u1->passkey, u2->passkey, u1->passkey_sz))
 		return false;
 
 	return true;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication
  2026-12-04 15:14 [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
@ 2026-12-04 15:14 ` Piyus Kedia
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
  2 siblings, 0 replies; 6+ messages in thread
From: Piyus Kedia @ 2026-12-04 15:14 UTC (permalink / raw)
  To: Namjae Jeon, linux-cifs
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, linux-kernel,
	Kapil Vaswani

Hi,

ksmbd_compare_user() compares two users' passkeys over the length of
the first one only:

  fs/smb/server/mgmt/user_config.c:108
      if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))

Each passkey is allocated by ksmbd_alloc_user() at the hash_sz of its
own login response from the user-space daemon:

  fs/smb/server/mgmt/user_config.c:59
      user->passkey_sz = resp->hash_sz;
      user->passkey = kmalloc(resp->hash_sz, KSMBD_DEFAULT_GFP);

so nothing makes u2's passkey as long as u1's.  ntlm_authenticate()
calls it when a client re-authenticates a session, with u1 the
session's user and u2 the user just logged in for this request
(fs/smb/server/smb2pdu.c:2344; the expired-session branch at 2355 makes
the same call).  When the second login response carried a shorter
hash, memcmp() reads past the end of the new passkey:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x51/0xd0 lib/string.c:665
  Read of size 8 at addr ffff888040fc1dc0 by task kworker/2:2/3253
  Workqueue: ksmbd-io handle_ksmbd_work
   memcmp+0x51/0xd0 lib/string.c:665
   bcmp+0x36/0x60 lib/string.c:697
   ksmbd_compare_user+0x97/0xd0 fs/smb/server/mgmt/user_config.c:108
   ntlm_authenticate+0x37e/0x9a0 fs/smb/server/smb2pdu.c:2344
   smb2_sess_setup+0x155e/0x1730 fs/smb/server/smb2pdu.c:2774
   __process_request+0x28f/0x4e0 fs/smb/server/server.c:163
   __handle_ksmbd_work+0x440/0xbc0 fs/smb/server/server.c:296
   handle_ksmbd_work+0x5f/0xa0 fs/smb/server/server.c:387

  Allocated by task 3253:
   __kmalloc_noprof+0x2ba/0x620 mm/slub.c:5562
   ksmbd_alloc_user+0x13b/0x360 fs/smb/server/mgmt/user_config.c:60
   ksmbd_login_user+0xb2/0x100 fs/smb/server/mgmt/user_config.c:28
   session_user+0x1ba/0x240 fs/smb/server/smb2pdu.c:2294
   ntlm_authenticate+0x212/0x9a0 fs/smb/server/smb2pdu.c:2328

  The buggy address belongs to the object at ffff888040fc1dc0
   which belongs to the cache kmalloc-8 of size 8
  The buggy address is located 0 bytes inside of
   allocated 1-byte region [ffff888040fc1dc0, ffff888040fc1dc1)

How it is reached.  The reproducer registers itself as the ksmbd
daemon over the ksmbd generic netlink family (KSMBD_EVENT_STARTING_UP),
then connects to the server over TCP as an SMB 3.1.1 client and does
an NTLMSSP session setup as user "u" twice on the same SessionId.  Its
daemon answers the two LOGIN_REQUESTs for "u" with hash_sz 18 and then
1, with KSMBD_USER_FLAG_GUEST_ACCOUNT set so the NTLMv2 check is
skipped and the first setup leaves the session valid.  The second
setup then compares the session's 18-byte passkey with the new 1-byte
one.  It has reproduced every time we ran it: five runs on two
kernels, one of them unprivileged (below).

Impact - who can trigger it:

  - The two lengths come from the daemon's login responses; an SMB
    client controls only the account name and the NTLMSSP blobs.  So
    the trigger is a daemon that reports a different hash size for the
    same account on a later login.  We have not found a way to make
    ksmbd.mountd do that from the network, but we have not audited
    ksmbd-tools either.  This is the trust boundary of 7405d0ba2943
    ("ksmbd: fix slab-out-of-bounds read in ksmbd_alloc_user()"),
    which bounds hash_sz from above; nothing bounds it from below
    against the session's earlier login.

  - With CONFIG_SMB_SERVER_CHECK_CAP_NET_ADMIN=y, the default,
    handle_startup_event() and handle_generic_event() require
    CAP_NET_ADMIN, checked by netlink_capable() against the initial
    user namespace.  An unprivileged user cannot register as the
    daemon or send it a login response, from a user namespace either,
    so on a default build this needs root (or a compromised or buggy
    daemon).

  - With that option disabled, neither handler checks anything.  We
    ran the same reproducer as uid 65534 with every capability dropped
    (CapEff and CapBnd 0), on a 7.4.0-rc5 build with the option off
    and no daemon running: it registered as the daemon and triggered
    the same KASAN report.  So on such a build any local user can
    trigger it while ksmbd.mountd is not running.  While it is
    running, handle_startup_event() refuses a second daemon, but
    handle_generic_event() matches a response to its request only by
    type and by a handle from an IDA, not by sender, so a forged
    LOGIN_RESPONSE from another process would be accepted as well; we
    have not tried that.

  - What the read does: it reads up to passkey_sz bytes from a
    shorter allocation, here 17 bytes past a 1-byte kmalloc-8 object.
    Nothing read is returned to the client; the bytes only decide
    whether the re-authentication is accepted or fails with
    -EKEYREJECTED.

Seen on 7.4.0-rc5 and REPRODUCED ON ksmbd-for-next (d70570cf8003,
2026-12-04) with KASAN.  On 7.4-rc5 the read came from the
valid-session call (smb2pdu.c:2344 there); on ksmbd-for-next the same
program reached it through the expired-session call, smb2pdu.c:2402:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0
  Read of size 8 at addr ffff88805834a120 by task kworker/1:0/26
   memcmp+0x8b/0xb0 lib/string.c:665
   ksmbd_compare_user+0x82/0xb0 fs/smb/server/mgmt/user_config.c:108
   smb2_sess_setup+0x222d/0x3610 fs/smb/server/smb2pdu.c:2402

ksmbd_compare_user() and both calls are the same in mainline
(007722b8211f, 2026-12-03).  The comparison has been this way since it
was added in a58b45a4dbfd ("ksmbd: set RSS capable in
FSCTL_QUERY_NETWORK_INTERFACE_INFO"), so v5.17 and later.

A patch follows in reply to this mail.  Users whose passkeys differ in
length are not the same user, so it compares the lengths before the
bytes.  On ksmbd-for-next, same config and image before and after,
only that change between the two builds:

  without the patch   KASAN slab-out-of-bounds read, as above
  with the patch      the same program runs to the end and the
                      re-authentication is rejected (STATUS_ACCESS_DENIED,
                      as before), no report, twice

This was found by AI-driven fuzzing built on top of syzkaller; its
analysis was then checked by hand against the code and every claim
above was reproduced.  The reproducer is fuzzer-generated, runs the
daemon and the client in one program over loopback, and we are happy
to send it on request.

Kapil Vaswani
Piyus Kedia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user()
  2026-12-04 15:14 [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
  2026-12-04 15:14 ` [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
@ 2026-12-04 15:14 ` Piyus Kedia
  2026-12-04 19:16   ` Ian Bridges
  2 siblings, 1 reply; 6+ messages in thread
From: Piyus Kedia @ 2026-12-04 15:14 UTC (permalink / raw)
  To: Namjae Jeon, linux-cifs
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, linux-kernel,
	Kapil Vaswani

ksmbd_compare_user() compares the passkeys of two users over the
length of the first one:

	if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))

Each passkey is allocated by ksmbd_alloc_user() at the hash_sz of its
own login response from the user-space daemon, so the second one can
be shorter.  ntlm_authenticate() makes this comparison when a session
is re-authenticated, valid or expired, between the session's user and
the user just logged in, and when the later login response carried a
smaller hash_sz, memcmp() reads past the end of the new passkey:

  BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0
  Read of size 8 at addr ffff88805834a120 by task kworker/1:0/26
  Workqueue: ksmbd-io handle_ksmbd_work
   memcmp+0x8b/0xb0 lib/string.c:665
   ksmbd_compare_user+0x82/0xb0 fs/smb/server/mgmt/user_config.c:108
   smb2_sess_setup+0x222d/0x3610 fs/smb/server/smb2pdu.c:2402
   handle_ksmbd_work+0x4d7/0x13d0 fs/smb/server/server.c:223
   process_one_work+0x6f7/0x11a0 kernel/workqueue.c:3497
   worker_thread+0x417/0x7b0 kernel/workqueue.c:3580

  Allocated by task 26:
   __kmalloc_noprof+0x357/0x810 mm/slub.c:5556
   ksmbd_alloc_user+0x122/0x2f0 fs/smb/server/mgmt/user_config.c:60
   ksmbd_login_user+0x7d/0xd0 fs/smb/server/mgmt/user_config.c:28
   smb2_sess_setup+0x2172/0x3610 fs/smb/server/smb2pdu.c:2375

  The buggy address belongs to the object at ffff88805834a120
   which belongs to the cache kmalloc-8 of size 8
  The buggy address is located 0 bytes inside of
   allocated 1-byte region [ffff88805834a120, ffff88805834a121)

Users whose passkeys differ in length are not the same user, so
compare the lengths before the bytes.

The lengths come from the daemon's login responses, so this takes a
daemon that reports a different hash size for the same account on a
later login.  Like the upper bound on hash_sz in ksmbd_alloc_user(),
the check keeps such a response from becoming an out-of-bounds read.

We found this with a syzkaller-based fuzzing harness driven by an AI tool.

Fixes: a58b45a4dbfd ("ksmbd: set RSS capable in FSCTL_QUERY_NETWORK_INTERFACE_INFO")
Closes: https://lore.kernel.org/linux-cifs/ksmbd-compare-user-passkey.20261204@iiitd.ac.in/
Cc: stable@vger.kernel.org
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
---
Tested on ksmbd-for-next (d70570cf8003) with KASAN, the same config and
image before and after, only this change between the two builds.  The
reproducer plays the user-space daemon over the ksmbd genetlink family,
answers the two LOGIN_REQUESTs for one account with hash_sz 18 and then
1, and re-authenticates an NTLMSSP session over TCP:

  before   KASAN slab-out-of-bounds read in memcmp, from the call at
           smb2pdu.c:2402 (on 7.4-rc5 the same read came from the
           valid-session call, then at smb2pdu.c:2344)
  after    the same program runs to the end, the re-authentication is
           rejected (STATUS_ACCESS_DENIED, as before), no report, twice

 fs/smb/server/mgmt/user_config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/mgmt/user_config.c b/fs/smb/server/mgmt/user_config.c
index 5efc3d7455b9..2bebf1ca0d80 100644
--- a/fs/smb/server/mgmt/user_config.c
+++ b/fs/smb/server/mgmt/user_config.c
@@ -105,7 +105,8 @@ bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2)
 {
 	if (strcmp(u1->name, u2->name))
 		return false;
-	if (memcmp(u1->passkey, u2->passkey, u1->passkey_sz))
+	if (u1->passkey_sz != u2->passkey_sz ||
+	    memcmp(u1->passkey, u2->passkey, u1->passkey_sz))
 		return false;
 
 	return true;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user()
  2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
@ 2026-12-04 19:16   ` Ian Bridges
  2026-12-05  2:48     ` Namjae Jeon
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Bridges @ 2026-12-04 19:16 UTC (permalink / raw)
  To: piyus
  Cc: linkinjeon, linux-cifs, senozhatsky, tom, chenxiaosong,
	linux-kernel, kapil, Ian Bridges

The size check makes the compare safe for every caller, including
ksmbd_krb5_authenticate(). destroy_previous_session() already checks
the passkey sizes the same way before its own memcmp(). A later
cleanup could have it call ksmbd_compare_user() instead.

Reviewed-by: Ian Bridges <icb@fastmail.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user()
  2026-12-04 19:16   ` Ian Bridges
@ 2026-12-05  2:48     ` Namjae Jeon
  0 siblings, 0 replies; 6+ messages in thread
From: Namjae Jeon @ 2026-12-05  2:48 UTC (permalink / raw)
  To: Ian Bridges
  Cc: piyus, linux-cifs, senozhatsky, tom, chenxiaosong, linux-kernel, kapil

On Sat, Dec 5, 2026 at 4:16 AM Ian Bridges <icb@fastmail.org> wrote:
>
> The size check makes the compare safe for every caller, including
> ksmbd_krb5_authenticate(). destroy_previous_session() already checks
> the passkey sizes the same way before its own memcmp(). A later
> cleanup could have it call ksmbd_compare_user() instead.
>
> Reviewed-by: Ian Bridges <icb@fastmail.org>
Applied it to #ksmbd-for-next.
Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-12-05  2:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 15:14 [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
2026-12-04 15:14 ` [BUG] ksmbd: slab-out-of-bounds read in ksmbd_compare_user() on session re-authentication Piyus Kedia
2026-12-04 15:14 ` [PATCH] ksmbd: compare the passkey lengths in ksmbd_compare_user() Piyus Kedia
2026-12-04 19:16   ` Ian Bridges
2026-12-05  2:48     ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®