Skip to content

Commit f0eb3f5

Browse files
namjaejeongregkh
authored andcommitted
ksmbd: fix use-after-free in ksmbd_sessions_deregister()
commit 15a9605f8d69dc85005b1a00c31a050b8625e1aa upstream. 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: [email protected] Reported-by: Norbert Szetei <[email protected]> Tested-by: Norbert Szetei <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 629dd37 commit f0eb3f5

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
@@ -229,6 +229,9 @@ void ksmbd_sessions_deregister(struct ksmbd_conn *conn)
229229
if (!ksmbd_chann_del(conn, sess) &&
230230
xa_empty(&sess->ksmbd_chann_list)) {
231231
hash_del(&sess->hlist);
232+
down_write(&conn->session_lock);
233+
xa_erase(&conn->sessions, sess->id);
234+
up_write(&conn->session_lock);
232235
ksmbd_session_destroy(sess);
233236
}
234237
}

0 commit comments

Comments
 (0)