ksmbd: check iov vector index in ksmbd_conn_write()
authorNamjae Jeon <linkinjeon@kernel.org>
Thu, 21 Sep 2023 06:37:06 +0000 (15:37 +0900)
committerSteve French <stfrench@microsoft.com>
Thu, 21 Sep 2023 19:41:06 +0000 (14:41 -0500)
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>
fs/smb/server/connection.c

index 0d990c2f33cda76f6aeba475b5b8b9d02d6582d6..db7fa704a3f60bf8d2dfe5e3bff79194f3651508 100644 (file)
@@ -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,