Commit 127b306d authored by 梁文韬's avatar 梁文韬 Committed by Yongjian Sun
Browse files

ksmbd: fix a missing return value check bug

mainline inclusion
from mainline-v6.12-rc3
commit 4c16e1cadcbcaf3c82d5fc310fbd34d0f5d0db7c
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBIQXA
CVE: CVE-2024-57925

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4c16e1cadcbcaf3c82d5fc310fbd34d0f5d0db7c



--------------------------------

In the smb2_send_interim_resp(), if ksmbd_alloc_work_struct()
fails to allocate a node, it returns a NULL pointer to the
in_work pointer. This can lead to an illegal memory write of
in_work->response_buf when allocate_interim_rsp_buf() attempts
to perform a kzalloc() on it.

To address this issue, incorporating a check for the return
value of ksmbd_alloc_work_struct() ensures that the function
returns immediately upon allocation failure, thereby preventing
the aforementioned illegal memory access.

Fixes: 041bba44 ("ksmbd: fix wrong interim response on compound")
Signed-off-by: default avatarWentao Liang <liangwentao@iscas.ac.cn>
Acked-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarYongjian Sun <sunyongjian1@huawei.com>
parent 6a2a7743
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -689,6 +689,9 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
	struct smb2_hdr *rsp_hdr;
	struct ksmbd_work *in_work = ksmbd_alloc_work_struct();

	if (!in_work)
		return;

	if (allocate_interim_rsp_buf(in_work)) {
		pr_err("smb_allocate_rsp_buf failed!\n");
		ksmbd_free_work_struct(in_work);