Skip to content

Commit 15a9605

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix use-after-free in ksmbd_sessions_deregister()
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 <norbert@doyensec.com> Tested-by: Norbert Szetei <norbert@doyensec.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 6955bfe commit 15a9605

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/smb/server/mgmt/user_session.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ void ksmbd_sessions_deregister(struct ksmbd_conn *conn)
230230
if (!ksmbd_chann_del(conn, sess) &&
231231
xa_empty(&sess->ksmbd_chann_list)) {
232232
hash_del(&sess->hlist);
233+
down_write(&conn->session_lock);
234+
xa_erase(&conn->sessions, sess->id);
235+
up_write(&conn->session_lock);
233236
ksmbd_session_destroy(sess);
234237
}
235238
}

0 commit comments

Comments
 (0)