]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: check iov vector index in ksmbd_conn_write()
authorNamjae Jeon <linkinjeon@kernel.org>
Sun, 31 Dec 2023 07:13:03 +0000 (16:13 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 14:18:33 +0000 (15:18 +0100)
[ 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 <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/server/connection.c

index d1f4ed18a227fa20c30edfe9472d8d8a65e77996..4b38c3a285f6028ea3bcdf9f7ecea957a1398e82 100644 (file)
@@ -199,6 +199,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,