linux/fs/smb/server/mgmt
Namjae Jeon d7fd1f9860 ksmbd: follow SMB2 session expiration semantics
ksmbd_session_register() destroys valid sessions after ten seconds of
inactivity whenever a client starts another SessionSetup exchange. This
confuses Session.IdleTime with Session.ExpirationTime. Windows can create
additional authenticated sessions on an existing connection, so deleting
the older session invalidates its tree connects and makes mapped drives
fail with STATUS_NETWORK_NAME_DELETED.

The session expiration rules require the server to change a valid session
to expired only after its credential expiration time passes. A valid or
expired session otherwise keeps its connection from being scavenged.
Connections that have not negotiated a dialect, have no sessions, or have
only InProgress sessions are disconnected after an implementation-specific
timeout. Use the Windows-compatible 45 second value and run the expiration
check periodically for both TCP and SMB Direct.

Keep zero as an infinite credential expiration time, and count each
Valid-to-Expired transition. Set expired sessions to InProgress when they
reauthenticate. If authentication fails, remove the session from the
global and per-connection tables immediately, including SMB3 multichannel
connections.

Retain protection against abandoned SessionId-zero exchanges by allowing
only one InProgress authentication per connection. Additional exchanges
fail with STATUS_INSUFFICIENT_RESOURCES, and stale InProgress sessions are
reaped after the same 45 second setup timeout. This bounds the original
unauthenticated memory-exhaustion path without evicting established
sessions.

Fixes: ea174a9189 ("ksmbd: destroy expired sessions")
Reported-by: Mobin Aydinfar <mobin@mobintestserver.ir>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
2026-09-14 20:14:35 +09:00
..
ksmbd_ida.c ksmbd: use __GFP_RETRY_MAYFAIL 2024-11-25 18:58:02 -06:00
ksmbd_ida.h
share_config.c ksmbd: prevent out-of-bounds reads in share config responses 2026-08-31 19:27:06 +09:00
share_config.h ksmbd: add procfs monitoring for active shares 2026-08-17 15:00:48 +09:00
tree_connect.c ksmbd: fix tree connection use-after-free in smb2_tree_connect() 2026-09-02 17:58:35 +09:00
tree_connect.h ksmbd: fix use-after-free in ksmbd_tree_connect_put under concurrency 2025-11-30 21:11:45 -06:00
user_config.c smb: server: Make sure that passkey is not leaked on the heap in user_config.c 2026-08-17 22:38:21 +09:00
user_config.h ksmbd: add procfs interface for runtime monitoring and statistics 2026-02-08 20:25:16 -06:00
user_session.c ksmbd: follow SMB2 session expiration semantics 2026-09-14 20:14:35 +09:00
user_session.h ksmbd: follow SMB2 session expiration semantics 2026-09-14 20:14:35 +09:00