Re: [PATCH] ksmbd: defer destroy_previous_session() until after NTLM authentication

From: Namjae Jeon

Date: Fri Jul 03 2026 - 01:02:00 EST


> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 5859fa68bb84..1ce13b23cf6c 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -1670,10 +1670,7 @@ static int ntlm_authenticate(struct ksmbd_work *work,
> return -EPERM;
> }
>
> - /* Check for previous session */
> prev_id = le64_to_cpu(req->PreviousSessionId);
Is there any specific reason for not moving this line together?

> - if (prev_id && prev_id != sess->id)
> - destroy_previous_session(conn, user, prev_id);
>
> if (sess->state == SMB2_SESSION_VALID) {
> /*
> @@ -1712,6 +1709,9 @@ static int ntlm_authenticate(struct ksmbd_work *work,
> }
> }
>
> + if (prev_id && prev_id != sess->id)
> + destroy_previous_session(conn, sess->user, prev_id);
> +
> /*
> * If session state is SMB2_SESSION_VALID, We can assume
> * that it is reauthentication. And the user/password
> --
> 2.47.3
>