linux/fs/smb/server
Namjae Jeon f363a0fb13 ksmbd: fix app-instance durable supersede session UAF
ksmbd_close_fd_app_instance_id() looks up a prior durable handle by
AppInstanceId and closes it through opinfo->sess->file_table. This is
unsafe after the original session has been torn down. session_fd_check()
preserves reconnectable durable handles in the global table and clears
opinfo->conn/fp->conn, but opinfo->sess can still point to the freed
ksmbd_session.

Use opinfo->conn as the orphan sentinel, but make the check reliable by
serializing it with session_fd_check(). That path clears opinfo->conn
under fp->f_ci->m_lock, so hold the same lock while testing opinfo->conn
and while dereferencing opinfo->sess->file_table. Also avoid closing
through the session file table if the volatile id has already been
unpublished by session teardown.

Durable reconnect must keep the two fields consistent. Rebinding only
opinfo->conn leaves opinfo->sess pointing at the old freed session, so
a later app-instance supersede can pass the conn check and write-lock the
freed session's file table. Clear opinfo->sess when preserving a durable
handle during session teardown, and set it to the reconnecting session
when opinfo->conn is rebound in ksmbd_reopen_durable_fd().

Fixes: 16c3064970 ("ksmbd: handle durable v2 app instance id")
Reported-by: Gil Portnoy <dddhkts1@gmail.com>
Co-developed-by: Gil Portnoy <dddhkts1@gmail.com>
Signed-off-by: Gil Portnoy <dddhkts1@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
2026-06-30 21:29:46 -05: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: validate NTLMv2 response before updating session key 2026-06-23 17:52:42 -05:00
auth.h ksmbd: Use AES-CMAC library for SMB3 signature calculation 2026-04-22 08:11:23 -05:00
compress.c ksmbd: compress SMB2 READ responses 2026-06-16 18:57:22 -05:00
compress.h ksmbd: compress SMB2 READ responses 2026-06-16 18:57:22 -05:00
connection.c ksmbd: negotiate and decode SMB2 compression 2026-06-16 18:57:22 -05:00
connection.h ksmbd: negotiate and decode SMB2 compression 2026-06-16 18:57:22 -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 treewide: Add SPDX identifier to IETF ASN.1 modules 2023-10-27 18:04:28 +08:00
ksmbd_spnego_negtokentarg.asn1 treewide: Add SPDX identifier to IETF ASN.1 modules 2023-10-27 18:04:28 +08:00
ksmbd_work.c ksmbd: keep common response iovecs in the work item 2026-06-22 20:15:04 -05:00
ksmbd_work.h ksmbd: fix outstanding credit leak on abort and error paths 2026-06-30 21:29:46 -05:00
Makefile ksmbd: negotiate and decode SMB2 compression 2026-06-16 18:57:22 -05:00
misc.c ksmbd: treat unnamed DATA stream as base file 2026-06-22 20:15:04 -05:00
misc.h ksmbd: fix path resolution in ksmbd_vfs_kern_path_create 2026-06-16 18:57:22 -05:00
ndr.c ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
ndr.h
ntlmssp.h
oplock.c ksmbd: snapshot previous oplock state before durable checks 2026-06-30 21:29:46 -05:00
oplock.h ksmbd: avoid level II oplock break notification on unlink 2026-06-22 20:15:05 -05:00
proc.c ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
server.c ksmbd: fix outstanding credit leak on abort and error paths 2026-06-30 21:29:46 -05:00
server.h ksmbd: add max ip connections parameter 2025-09-30 21:37:54 -05:00
smb_common.c ksmbd: negotiate and decode SMB2 compression 2026-06-16 18:57:22 -05:00
smb_common.h smb: move filesystem_vol_info into common/fscc.h 2026-04-12 18:07:54 -05:00
smb2misc.c ksmbd: fix outstanding credit leak on abort and error paths 2026-06-30 21:29:46 -05:00
smb2ops.c ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
smb2pdu.c smb/server: do not require delete access for non-replacing links 2026-06-30 21:29:46 -05:00
smb2pdu.h ksmbd: increase SMB3_DEFAULT_TRANS_SIZE from 1MB to 4MB 2026-06-22 20:15:06 -05:00
smbacl.c ksmbd: validate num_subauth when copying ACE in set_ntacl_dacl 2026-06-30 21:29:46 -05:00
smbacl.h ksmbd: fix OOB write in QUERY_INFO for compound requests 2026-03-29 22:07:45 -05:00
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 fs/smb: Swing unicode common code from smb->NLS 2023-08-30 08:55:51 -05:00
vfs_cache.c ksmbd: fix app-instance durable supersede session UAF 2026-06-30 21:29:46 -05:00
vfs_cache.h ksmbd: start file id allocation at 1 2026-06-22 20:15:06 -05:00
vfs.c ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr 2026-06-30 21:29:45 -05:00
vfs.h smb/server: implement FSCTL_SET_COMPRESSION ioctl handler 2026-06-16 18:57:21 -05:00
xattr.h ksmbd: Correct typos in multiple comments across various files 2024-09-25 21:33:22 -05:00