From 7014eff6a11adf532a9dd9af078de6d641e7c30e Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Thu, 24 Apr 2025 14:45:32 +0800 Subject: [PATCH] ksmbd: fix use-after-free in ksmbd_sessions_deregister() mainline inclusion from mainline-v6.15-rc1 commit 15a9605f8d69dc85005b1a00c31a050b8625e1aa category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IC1QTG CVE: CVE-2025-22041 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=15a9605f8d69dc85005b1a00c31a050b8625e1aa -------------------------------- In multichannel mode, UAF issue can occur in session_deregister when the second channel sets up a session through the connection of the first channel. session that is freed through the global session table can be accessed again through ->sessions of connection. Cc: stable@vger.kernel.org Reported-by: Norbert Szetei Tested-by: Norbert Szetei Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Wang Zhaolong --- fs/smb/server/mgmt/user_session.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/smb/server/mgmt/user_session.c b/fs/smb/server/mgmt/user_session.c index 9a134181df61..e1aabe889c61 100644 --- a/fs/smb/server/mgmt/user_session.c +++ b/fs/smb/server/mgmt/user_session.c @@ -229,6 +229,9 @@ void ksmbd_sessions_deregister(struct ksmbd_conn *conn) if (!ksmbd_chann_del(conn, sess) && xa_empty(&sess->ksmbd_chann_list)) { hash_del(&sess->hlist); + down_write(&conn->session_lock); + xa_erase(&conn->sessions, sess->id); + up_write(&conn->session_lock); ksmbd_session_destroy(sess); } } -- Gitee