This is a note to let you know that I've just added the patch titled ksmbd: fix memory leak in smb2_handle_negotiate to the 5.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ksmbd-fix-memory-leak-in-smb2_handle_negotiate.patch and it can be found in the queue-5.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 1aee2ce6d6f534f164521c98e4804bd102190706 Author: Namjae Jeon <linkinjeon@xxxxxxxxxx> Date: Thu Jul 28 21:56:19 2022 +0900 ksmbd: fix memory leak in smb2_handle_negotiate [ Upstream commit aa7253c2393f6dcd6a1468b0792f6da76edad917 ] The allocated memory didn't free under an error path in smb2_handle_negotiate(). Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: stable@xxxxxxxxxxxxxxx Reported-by: zdi-disclosures@xxxxxxxxxxxxxx # ZDI-CAN-17815 Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 353f047e783c..a06dad0d1bb7 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -1139,12 +1139,16 @@ int smb2_handle_negotiate(struct ksmbd_work *work) status); rsp->hdr.Status = status; rc = -EINVAL; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; } rc = init_smb3_11_server(conn); if (rc < 0) { rsp->hdr.Status = STATUS_INVALID_PARAMETER; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; }