Skip to content

Commit cafb57f

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: Fix refcount leak when invalid session is found on session lookup
When a session is found but its state is not SMB2_SESSION_VALID, It indicates that no valid session was found, but it is missing to decrement the reference count acquired by the session lookup, which results in a reference count leak. This patch fixes the issue by explicitly calling ksmbd_user_session_put to release the reference to the session. Cc: stable@vger.kernel.org Reported-by: Alexandre <roger.andersen@protonmail.com> Reported-by: Stanislas Polu <spolu@dust.tt> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 8dd2e58 commit cafb57f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/smb/server/mgmt/user_session.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,10 @@ struct ksmbd_session *ksmbd_session_lookup_all(struct ksmbd_conn *conn,
325325
sess = ksmbd_session_lookup(conn, id);
326326
if (!sess && conn->binding)
327327
sess = ksmbd_session_lookup_slowpath(id);
328-
if (sess && sess->state != SMB2_SESSION_VALID)
328+
if (sess && sess->state != SMB2_SESSION_VALID) {
329+
ksmbd_user_session_put(sess);
329330
sess = NULL;
331+
}
330332
return sess;
331333
}
332334

0 commit comments

Comments
 (0)