projects/linux·commit 73f949ea

ksmbd: check iov vector index in ksmbd_conn_write()

73f949ea · Namjae Jeon <[email protected]> · 2023-09-21 15:37:06 +09:00

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 <[email protected]>
Signed-off-by: Steve French <[email protected]>
Commit
73f949ea87c7d697210653501ca21efe57295327
Parents
f2f11fca

Changes

1 files changed · +3 −0

FileStatusAddDelContent
fs/smb/server/connection.cmodified+3−0View file

fs/smb/server/connection.c

View file
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index 0d990c2..db7fa70 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -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,