Skip to content

Commit 4c16e1c

Browse files
rwnbiad105smfrench
authored andcommitted
ksmbd: fix a missing return value check bug
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: 041bba4 ("ksmbd: fix wrong interim response on compound") Signed-off-by: Wentao Liang <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 9d89551 commit 4c16e1c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
695695
struct smb2_hdr *rsp_hdr;
696696
struct ksmbd_work *in_work = ksmbd_alloc_work_struct();
697697

698+
if (!in_work)
699+
return;
700+
698701
if (allocate_interim_rsp_buf(in_work)) {
699702
pr_err("smb_allocate_rsp_buf failed!\n");
700703
ksmbd_free_work_struct(in_work);

0 commit comments

Comments
 (0)