From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E881263F44; Sat, 30 May 2026 17:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161729; cv=none; b=mQt49rEM5Xp+QPp/6RZpodzdasJDClyWbfXW8l2WOCgATZAPlKAADQZZsfw2OZfsq2ZiedR+SvJBdZltfBtuBKaNWWWSSQxzCYAH58yy96BMnuvppy2aOQ19y7HIsjHlI310hssdNmKRiAiX9dTZl2E2DVUZz1kFG6A8TTUQwQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161729; c=relaxed/simple; bh=sZ1bqXZ8FAkS5/JDR4VTQ+JX4eUhndmEPUsDiK90uKY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AyRcvjjNitKKEJkNtPvGfVFT5/lM181cvmyt+Ha3gPQ9FGx10z8lbqTHZIGTU8pF4gmvoB3LlgvSDOPzq6+s1rcazVJFqYrt7/hBa7adThPiLhJkvsWY+tJdNbsFGjCUmBm+wBPrOSBvqKtRzzhxshbZxEwI1OceN6xNZmyIpzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xGS0JktR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xGS0JktR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 729EB1F00893; Sat, 30 May 2026 17:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780161728; bh=7ko/OY42WBS7u4N8COLJDh9MLz6Yb6hg6hb0xt8A6tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xGS0JktR00kB93HdE1LlBEtV4VU/dk4hAjPpvqwBzL84NF8ut82mYw+xwvUWBB2sR nng+lC0fyjTfexTxIu+uRArhA1KXuNhq+Ij1QkCRp2M76t7jz4D40IG7zLiwZZLE3e xLB2u+YCAmY6Hz57RJC9ho5PO7KNTelbjzETArNU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, DaeMyung Kang , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.1 710/969] ksmbd: destroy tree_conn_ida in ksmbd_session_destroy() Date: Sat, 30 May 2026 18:03:54 +0200 Message-ID: <20260530160320.137840890@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: DaeMyung Kang [ Upstream commit c049ee14eb4343b69b6f7755563f961f5e153423 ] When per-session tree_conn_ida was converted from a dynamically allocated ksmbd_ida to an embedded struct ida, ksmbd_ida_free() was removed from ksmbd_session_destroy() but no matching ida_destroy() was added. The session is therefore freed with the IDA's backing xarray still intact. The kernel IDA API expects ida_init() and ida_destroy() to be paired over an object's lifetime, so add the missing cleanup before the enclosing session is freed. Also move ida_init() to right after the session is allocated so that it is always paired with the destroy call even on the early error paths of __session_create() (ksmbd_init_file_table() or __init_smb2_session() failures), both of which jump to the error label and invoke ksmbd_session_destroy() on a partially initialised session. No leak has been observed in testing; this is a pairing fix to match the IDA lifetime rules, not a response to a reproduced regression. Fixes: d40012a83f87 ("cifsd: declare ida statically") Signed-off-by: DaeMyung Kang Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/mgmt/user_session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/smb/server/mgmt/user_session.c b/fs/smb/server/mgmt/user_session.c index 1b5ac28d7e66c..f7ba243c854e2 100644 --- a/fs/smb/server/mgmt/user_session.c +++ b/fs/smb/server/mgmt/user_session.c @@ -168,6 +168,7 @@ void ksmbd_session_destroy(struct ksmbd_session *sess) free_channel_list(sess); kfree(sess->Preauth_HashValue); ksmbd_release_id(&session_ida, sess->id); + ida_destroy(&sess->tree_conn_ida); kfree(sess); } @@ -404,6 +405,8 @@ static struct ksmbd_session *__session_create(int protocol) if (!sess) return NULL; + ida_init(&sess->tree_conn_ida); + if (ksmbd_init_file_table(&sess->file_table)) goto error; @@ -422,8 +425,6 @@ static struct ksmbd_session *__session_create(int protocol) if (ret) goto error; - ida_init(&sess->tree_conn_ida); - down_write(&sessions_table_lock); hash_add(sessions_table, &sess->hlist, sess->id); up_write(&sessions_table_lock); -- 2.53.0