From: Namjae Jeon Date: Mon, 18 Dec 2023 15:34:30 +0000 (+0900) Subject: ksmbd: check iov vector index in ksmbd_conn_write() X-Git-Tag: v5.15.145~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9a3e4549676857bf4b1b5f92200fbb1740dfa2e;p=thirdparty%2Fkernel%2Fstable.git ksmbd: check iov vector index in ksmbd_conn_write() [ Upstream commit 73f949ea87c7d697210653501ca21efe57295327 ] 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 Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ksmbd/connection.c b/fs/ksmbd/connection.c index 585f117bda8a2..9e12738a56c65 100644 --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/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,