Skip to content

Commit

Permalink
ksmbd: check iov vector index in ksmbd_conn_write()
Browse files Browse the repository at this point in the history
If ->iov_idx is zero, This means that the iov vector for the response
was not added during the request process. In other words, it means that
there is a problem in generating a response, So this patch return as
an error to avoid NULL pointer dereferencing problem.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Namjae Jeon authored and Steve French committed Sep 21, 2023
1 parent f2f11fc commit 73f949e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/smb/server/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ int ksmbd_conn_write(struct ksmbd_work *work)
if (work->send_no_response)
return 0;

if (!work->iov_idx)
return -EINVAL;

ksmbd_conn_lock(conn);
sent = conn->transport->ops->writev(conn->transport, work->iov,
work->iov_cnt,
Expand Down

0 comments on commit 73f949e

Please sign in to comment.