milos-linux/fs/smb/server
Gil Portnoy 5f983b864d ksmbd: reject non-VALID session in compound request branch
commit 609ca17d869d04ba249e32cdcbf13c0b1c66f43c upstream.

smb2_check_user_session() takes a shortcut for any operation that is not
the first in a COMPOUND request: it reuses work->sess (the session bound by
the first operation) and validates only the SessionId, then returns
"valid". It never re-checks work->sess->state == SMB2_SESSION_VALID, and a
SessionId of 0xFFFFFFFFFFFFFFFF (ULLONG_MAX, the MS-SMB2 related-operation
value) skips even the id comparison. The standalone path
(ksmbd_session_lookup_all() plus the SESSION_SETUP state machine) does
enforce the VALID state; the compound branch bypasses all of it.

A SESSION_SETUP carrying only an NTLM Type-1 (NtLmNegotiate) blob publishes
a fresh SMB2_SESSION_IN_PROGRESS session whose sess->user is still NULL
(->user is assigned later, by ntlm_authenticate()). Used as operation 1 of
a COMPOUND with operation 2 = TREE_CONNECT (related, SessionId=ULLONG_MAX,
\\host\IPC$), the tree-connect then runs on that IN_PROGRESS session and
reaches ksmbd_ipc_tree_connect_request(), which dereferences
user_name(sess->user) with sess->user == NULL (transport_ipc.c:687/701/704)
-> remote NULL-pointer dereference and a kernel Oops that wedges the ksmbd
worker for all clients.

Reject any non-first compound operation that lands on a session which is
not SMB2_SESSION_VALID, mirroring the validity the standalone lookup path
enforces. SESSION_SETUP itself legitimately runs on an IN_PROGRESS session,
but it is never carried as a non-first compound operation, so multi-leg
authentication is unaffected by this check.

Fixes: 5005bcb421 ("ksmbd: validate session id and tree id in the compound request")
Cc: stable@vger.kernel.org
Signed-off-by: Gil Portnoy <dddhkts1@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-06-27 11:08:17 +01:00
..
mgmt ksmbd: fail share config requests when path allocation fails 2026-05-01 21:49:35 -05:00
asn1.c ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
asn1.h
auth.c ksmbd: Use AES-CMAC library for SMB3 signature calculation 2026-04-22 08:11:23 -05:00
auth.h ksmbd: Use AES-CMAC library for SMB3 signature calculation 2026-04-22 08:11:23 -05:00
connection.c ksmbd: fix kernel-doc warnings from ksmbd_conn_get/put() 2026-05-01 21:49:35 -05:00
connection.h ksmbd: centralize ksmbd_conn final release to plug transport leak 2026-05-01 21:49:35 -05:00
crypto_ctx.c ksmbd: Use AES-CMAC library for SMB3 signature calculation 2026-04-22 08:11:23 -05:00
crypto_ctx.h ksmbd: Use AES-CMAC library for SMB3 signature calculation 2026-04-22 08:11:23 -05:00
glob.h ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
Kconfig smb: smbdirect: move fs/smb/common/smbdirect/ to fs/smb/smbdirect/ 2026-04-22 19:00:41 -05:00
ksmbd_netlink.h ksmbd: add max ip connections parameter 2025-09-30 21:37:54 -05:00
ksmbd_spnego_negtokeninit.asn1
ksmbd_spnego_negtokentarg.asn1
ksmbd_work.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
ksmbd_work.h ksmbd: fix use-after-free in ksmbd_free_work_struct 2025-03-10 12:54:28 -05:00
Makefile ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
misc.c ksmbd: Replace strcpy + strcat to improve convert_to_nt_pathname 2025-11-30 21:11:45 -06:00
misc.h ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
ndr.c ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
ndr.h
ntlmssp.h
oplock.c ksmbd: fix NULL-deref of opinfo->conn in oplock/lease break notifiers 2026-05-31 19:13:48 -05:00
oplock.h ksmbd: validate owner of durable handle on reconnect 2026-04-12 18:07:54 -05:00
proc.c ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
server.c ksmbd: centralize ksmbd_conn final release to plug transport leak 2026-05-01 21:49:35 -05:00
server.h ksmbd: add max ip connections parameter 2025-09-30 21:37:54 -05:00
smb2misc.c smb/server: remove unused nterr.h 2025-12-09 21:01:16 -06:00
smb2ops.c ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
smb2pdu.c ksmbd: reject non-VALID session in compound request branch 2026-06-27 11:08:17 +01:00
smb2pdu.h smb: move file_basic_info into common/fscc.h 2026-04-12 18:07:54 -05:00
smb_common.c ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
smb_common.h smb: move filesystem_vol_info into common/fscc.h 2026-04-12 18:07:54 -05:00
smbacl.c ksmbd: OOB read regression in smb_check_perm_dacl() ACE-walk loops 2026-05-26 20:36:36 -05:00
smbacl.h ksmbd: fix OOB write in QUERY_INFO for compound requests 2026-03-29 22:07:45 -05:00
smbfsctl.h
stats.h ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
transport_ipc.c ksmbd: validate response sizes in ipc_validate_msg() 2026-04-18 12:19:59 -05:00
transport_ipc.h ksmbd: Remove unused functions 2025-01-15 23:24:51 -06:00
transport_rdma.c smb: smbdirect: introduce and use include/linux/smbdirect.h 2026-05-01 16:24:25 -05:00
transport_rdma.h smb: smbdirect: introduce and use include/linux/smbdirect.h 2026-05-01 16:24:25 -05:00
transport_tcp.c smb: server: fix max_connections off-by-one in tcp accept path 2026-04-18 12:19:59 -05:00
transport_tcp.h ksmbd: fix use-after-free in __smb2_lease_break_noti() 2025-04-14 22:21:26 -05:00
unicode.c ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
unicode.h
vfs.c vfs-7.0-rc1.misc.2 2026-02-16 13:00:36 -08:00
vfs.h smb/server: use end_removing_noperm for for target of smb2_create_link() 2025-11-14 13:15:56 +01:00
vfs_cache.c ksmbd: fix durable reconnect double-bind race in ksmbd_reopen_durable_fd 2026-05-31 19:13:48 -05:00
vfs_cache.h ksmbd: harden file lifetime during session teardown 2026-05-01 21:49:35 -05:00
xattr.h ksmbd: Correct typos in multiple comments across various files 2024-09-25 21:33:22 -05:00