From: Jacob Keller <jacob.e.keller@intel.com>
To: Kees Cook <kees@kernel.org>, "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
kvm@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] vhost: vringh: Use matching allocation type in resize_iovec()
Date: Wed, 30 Apr 2025 13:54:51 -0700 [thread overview]
Message-ID: <f20ffdf1-7566-4466-9e92-b6d9878b6fd1@intel.com> (raw)
In-Reply-To: <20250426062214.work.334-kees@kernel.org>
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@kernel.org>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
prev parent reply other threads:[~2025-04-30 20:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-26 6:22 [PATCH] vhost: vringh: Use matching allocation type in resize_iovec() Kees Cook
2025-04-29 3:37 ` Jason Wang
2025-04-30 20:54 ` Jacob Keller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f20ffdf1-7566-4466-9e92-b6d9878b6fd1@intel.com \
--to=jacob.e.keller@intel.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kees@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox