Skip to content

Commit

Permalink
ksmbd: Fix dangling pointer in krb_authenticate
Browse files Browse the repository at this point in the history
krb_authenticate frees sess->user and does not set the pointer
to NULL. It calls ksmbd_krb5_authenticate to reinitialise
sess->user but that function may return without doing so. If
that happens then smb2_sess_setup, which calls krb_authenticate,
will be accessing free'd memory when it later uses sess->user.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Heelan <seanheelan@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Sean Heelan authored and Steve French committed Apr 15, 2025
1 parent 8ffd015 commit 1e440d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/smb/server/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,8 +1602,10 @@ static int krb5_authenticate(struct ksmbd_work *work,
if (prev_sess_id && prev_sess_id != sess->id)
destroy_previous_session(conn, sess->user, prev_sess_id);

if (sess->state == SMB2_SESSION_VALID)
if (sess->state == SMB2_SESSION_VALID) {
ksmbd_free_user(sess->user);
sess->user = NULL;
}

retval = ksmbd_krb5_authenticate(sess, in_blob, in_len,
out_blob, &out_len);
Expand Down

0 comments on commit 1e440d5

Please sign in to comment.