mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
ksmbd: fix a missing return value check bug
[ Upstream commit 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: 041bba4414 ("ksmbd: fix wrong interim response on compound")
Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f05f5ab5e7
commit
ee7e40f7fb
@@ -712,6 +712,9 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
|
|||||||
struct smb2_hdr *rsp_hdr;
|
struct smb2_hdr *rsp_hdr;
|
||||||
struct ksmbd_work *in_work = ksmbd_alloc_work_struct();
|
struct ksmbd_work *in_work = ksmbd_alloc_work_struct();
|
||||||
|
|
||||||
|
if (!in_work)
|
||||||
|
return;
|
||||||
|
|
||||||
if (allocate_interim_rsp_buf(in_work)) {
|
if (allocate_interim_rsp_buf(in_work)) {
|
||||||
pr_err("smb_allocate_rsp_buf failed!\n");
|
pr_err("smb_allocate_rsp_buf failed!\n");
|
||||||
ksmbd_free_work_struct(in_work);
|
ksmbd_free_work_struct(in_work);
|
||||||
|
|||||||
Reference in New Issue
Block a user