[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f20ffdf1-7566-4466-9e92-b6d9878b6fd1@intel.com>
Date: Wed, 30 Apr 2025 13:54:51 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: Kees Cook <kees@...nel.org>, "Michael S. Tsirkin" <mst@...hat.com>
CC: Jason Wang <jasowang@...hat.com>, Eugenio Pérez
<eperezma@...hat.com>, <kvm@...r.kernel.org>,
<virtualization@...ts.linux.dev>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-hardening@...r.kernel.org>
Subject: Re: [PATCH] vhost: vringh: Use matching allocation type in
resize_iovec()
On 4/25/2025 11:22 PM, Kees Cook wrote:
> In preparation for making the kmalloc family of allocators type aware,
> we need to make sure that the returned type from the allocation matches
> the type of the variable being assigned. (Before, the allocator would
> always return "void *", which can be implicitly cast to any pointer type.)
>
> The assigned type is "struct kvec *", but the returned type will be
> "struct iovec *". These have the same allocation size, so there is no
> bug:
>
> struct kvec {
> void *iov_base; /* and that should *never* hold a userland pointer */
> size_t iov_len;
> };
>
> struct iovec
> {
> void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
> __kernel_size_t iov_len; /* Must be size_t (1003.1g) */
> };
>
> Adjust the allocation type to match the assignment.
>
> Signed-off-by: Kees Cook <kees@...nel.org>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
Powered by blists - more mailing lists