Skip to content

Commit 1e440d5

Browse files
SeanHeelanSteve French
authored andcommitted
ksmbd: Fix dangling pointer in krb_authenticate
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>
1 parent 8ffd015 commit 1e440d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,10 @@ static int krb5_authenticate(struct ksmbd_work *work,
16021602
if (prev_sess_id && prev_sess_id != sess->id)
16031603
destroy_previous_session(conn, sess->user, prev_sess_id);
16041604

1605-
if (sess->state == SMB2_SESSION_VALID)
1605+
if (sess->state == SMB2_SESSION_VALID) {
16061606
ksmbd_free_user(sess->user);
1607+
sess->user = NULL;
1608+
}
16071609

16081610
retval = ksmbd_krb5_authenticate(sess, in_blob, in_len,
16091611
out_blob, &out_len);

0 commit comments

Comments
 (0)