Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795021400; b=Uj4kQWje1ElP/PG3Ltzt+Cv603MtbJwrTeSQJSpBY3aLnS3c7TnL0A41mvpjjjk0W48T xT2Jy8tO7mxxhoyOP9e0Oj6aWtr3uTOISao/VnmiLW1ViS2aCRUViPNeTAyGXXav/XDXP 2kUT20kuqgD0Dtqnf+cX05TKFOa9TWWAjtiYwx082WH2VagANy+4tP26BFBjoD1ujX0Gc umRmz+vyHj4gnXb+ifLfvj3fL++KeTPNvk3sstAh9bNfBfV8nxz93ZKYWxBV7AwbxZYt1 JGtZc6Hegm+H4m3a74g5//es+UFCG7j0+i1XuwxpKMMhT2fn8dv9W248kp8U+zYFZRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795021400; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YsQGeNcnlWqCmKRboMpyzj6uIaOiQx3jig1a2pavZmk=; b=oT9k227bYscD/k6UpJnrxVx1dLlRVSsQkWTW0rOOYuIPvD+2ChyLPChrt7GdfiGzIORu ZUdKvUAqh2slhbxXIH8SvDE+pSuJe/06BwouUdte16tOmC9H67kMIx3FQzbDMr3rLuE9+ At6hb6z1o5Jn1jR7r++2h4FweiSd4Ktoca4m1KkKU2bxb2Vs/kkWsw+98fA80CKJluSl8 /squPU1x1dYHzSSkGUHkQ98/VRQ1z2+2bSFiBkOQJajnLLtVSfNNlQ2JvFg0Dc+xheY3W 5fvKKH3dgh4dMhSgpBkWLZnpgOFP/I2PQX8NhmtaL+/po/UePPHhFOMOY0yUVnexTbQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OqDIJPgv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5AB960A2603; Wed, 18 Nov 2026 17:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OqDIJPgv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 063211F000C4; Wed, 18 Nov 2026 17:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795021400; bh=YsQGeNcnlWqCmKRboMpyzj6uIaOiQx3jig1a2pavZmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OqDIJPgvCfuaJPto9wNDHt5qQSCDsou1x3o8zt8qhvGmeKIeW8hMT1+njh9O7gPMu jFuy9LbMgT7VIGll2W7ip29+Iueckhc2AdJEwrV0U5qi8OQh31H4aHYqa04OxeCLeZ BOSUMJY7lnvmUd9LqF5wc7nvhbwCIQhdolmOSxiY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pan Guihua , Namjae Jeon , Sasha Levin Subject: [PATCH 7.3 2294/2651] ksmbd: keep lease tables until their last lease is closed Date: Wed, 18 Nov 2026 15:58:54 +0100 Message-ID: <20261118150407.837181353@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon [ Upstream commit 20e3068315423e6e493588dd94d462c8e7fd3a2e ] Disconnecting one channel destroys the lease table for its ClientGuid, even when another channel still uses the same opens. A lease break ACK on the surviving channel can no longer find the lease. Detached durable opens also lose their lease lookup entries before reconnect or expiry. Tie a client table to its lease entries instead of the connection which created it. Remove the table when its last lease is removed, and release any remaining entries at server shutdown. Do not destroy client tables from connection teardown or keep a connection reference in each table. For a detached lease, collect break candidates using the table's ClientGuid directly. The existing notification retry path takes its own references on matching live connections. Fixes: 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers") Reported-by: Pan Guihua Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin --- fs/smb/server/oplock.c | 46 +++++++++++++++++------------------------- fs/smb/server/oplock.h | 3 +-- fs/smb/server/server.c | 3 +-- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c index 313bf01ad3508..96b36b8329a66 100644 --- a/fs/smb/server/oplock.c +++ b/fs/smb/server/oplock.c @@ -125,6 +125,12 @@ static void lease_add_table(struct lease *lease, struct lease_table *lb) spin_unlock(&lb->lb_lock); } +static void free_lease_table(struct lease_table *lb) +{ + kfree(lb); +} + +/* The caller holds lease_list_lock for write. */ static void lease_del_table(struct lease *lease) { struct lease_table *lb = lease->l_lb; @@ -143,6 +149,10 @@ static void lease_del_table(struct lease *lease) spin_unlock(&lb->lb_lock); lease_put(lease); + if (list_empty(&lb->lease_list)) { + list_del(&lb->l_entry); + free_lease_table(lb); + } } static struct lease_table *alloc_lease_table(struct oplock_info *opinfo) @@ -155,21 +165,11 @@ static struct lease_table *alloc_lease_table(struct oplock_info *opinfo) memcpy(lb->client_guid, opinfo->conn->ClientGUID, SMB2_CLIENT_GUID_SIZE); - lb->conn = ksmbd_conn_get(opinfo->conn); INIT_LIST_HEAD(&lb->lease_list); spin_lock_init(&lb->lb_lock); return lb; } -static void free_lease_table(struct lease_table *lb) -{ - if (!lb) - return; - - ksmbd_conn_put(lb->conn); - kfree(lb); -} - static struct lease *alloc_lease(struct lease_ctx_info *lctx, struct ksmbd_inode *ci) { @@ -927,8 +927,6 @@ static int smb2_break_collect_channels(struct oplock_info *opinfo, if (lb) { memcpy(guid, lb->client_guid, sizeof(guid)); have_guid = true; - if (lb->conn) - owner->conn = ksmbd_conn_get(lb->conn); } read_unlock(&lease_list_lock); } @@ -1495,25 +1493,17 @@ static void oplock_break_drain_none(struct list_head *head, } } -void destroy_lease_table(struct ksmbd_conn *conn) +void destroy_lease_table(void) { - struct lease_table *lb, *lbtmp; - struct lease *lease, *ltmp; + struct lease_table *lb; + struct lease *lease; write_lock(&lease_list_lock); - if (list_empty(&lease_table_list)) { - write_unlock(&lease_list_lock); - return; - } - - list_for_each_entry_safe(lb, lbtmp, &lease_table_list, l_entry) { - if (conn && memcmp(lb->client_guid, conn->ClientGUID, - SMB2_CLIENT_GUID_SIZE)) - continue; - list_for_each_entry_safe(lease, ltmp, &lb->lease_list, l_entry) - lease_del_table(lease); - list_del(&lb->l_entry); - free_lease_table(lb); + while (!list_empty(&lease_table_list)) { + lb = list_first_entry(&lease_table_list, struct lease_table, + l_entry); + lease = list_first_entry(&lb->lease_list, struct lease, l_entry); + lease_del_table(lease); } write_unlock(&lease_list_lock); } diff --git a/fs/smb/server/oplock.h b/fs/smb/server/oplock.h index e114e2148c30e..5ef05166e5020 100644 --- a/fs/smb/server/oplock.h +++ b/fs/smb/server/oplock.h @@ -34,7 +34,6 @@ struct lease_ctx_info { struct lease_table { char client_guid[SMB2_CLIENT_GUID_SIZE]; - struct ksmbd_conn *conn; struct list_head lease_list; struct list_head l_entry; spinlock_t lb_lock; @@ -122,7 +121,7 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn, char *lease_key); int find_same_lease_key(struct ksmbd_conn *conn, struct ksmbd_inode *ci, struct lease_ctx_info *lctx); -void destroy_lease_table(struct ksmbd_conn *conn); +void destroy_lease_table(void); void smb_send_parent_lease_break_noti(struct ksmbd_file *fp, struct lease_ctx_info *lctx); void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp); diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c index 0593094f5fd08..c836e75b4825c 100644 --- a/fs/smb/server/server.c +++ b/fs/smb/server/server.c @@ -436,7 +436,6 @@ static int ksmbd_server_process_request(struct ksmbd_conn *conn) static int ksmbd_server_terminate_conn(struct ksmbd_conn *conn) { ksmbd_conn_sessions_cleanup(conn); - destroy_lease_table(conn); return 0; } @@ -666,7 +665,7 @@ static int ksmbd_server_shutdown(void) ksmbd_proc_cleanup(); ksmbd_crypto_destroy(); ksmbd_free_global_file_table(); - destroy_lease_table(NULL); + destroy_lease_table(); ksmbd_work_pool_destroy(); ksmbd_exit_file_cache(); server_conf_free(); -- 2.53.0