Skip to content

ksmbd: connection accounting and session teardown fixes

DaeMyung Kang linux-cifs lkml stable 1 version Applied

Status from this message: Applied it to #ksmbd-for-next-next.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2ksmbd: fix active_num_conn leak when alloc_transport() failsfs/smb/server/transport_tcp.c+2 -01 reply
2/2ksmbd: reset rcount per connection in ksmbd_conn_wait_idle_sess_id()fs/smb/server/connection.c+2 -31 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] ksmbd: connection accounting and session teardown fixes

Two independent correctness fixes in the ksmbd server.

1/2 ksmbd_tcp_new_connection() does not decrement active_num_conn on
the alloc_transport() failure path, so repeated allocation failures monotonically inflate the counter until max_connections is reached and new clients are refused indefinitely. This is the remaining half of the same family of accounting bugs addressed by 77ffbcac4e56 ("smb: server: fix leak of active_num_conn in ksmbd_tcp_new_connection()"), which only closed the kthread_run() failure path. Reproduced under a debug build that forces alloc_transport() to return NULL for a bounded number of calls; details in the commit log.

2/2 ksmbd_conn_wait_idle_sess_id() stores its per-connection
threshold (rcount) in cross-iteration state, so whether a given sibling connection is compared against the loose (< 2) or the strict (< 1) threshold is decided by hash iteration order relative to curr_conn. Connections visited after curr_conn can slip through the idle check while still processing requests against the same session, reopening the teardown race destroy_previous_session() was meant to close. This is a code-inspection fix; the iteration-order dependency makes a targeted reproducer impractical.

The two patches are independent; the series order is not significant.

DaeMyung Kang (2):
ksmbd: fix active_num_conn leak when alloc_transport() fails
ksmbd: reset rcount per connection in ksmbd_conn_wait_idle_sess_id()

 fs/smb/server/connection.c    | 5 ++---
 fs/smb/server/transport_tcp.c | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

--
2.43.0