dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pavel Begunkov" <asml.silence@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v9 10/13] io_uring/rsrc: extend buffer update
Date: Wed, 07 Oct 2026 01:51:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-162571@kernel.org> (raw)
In-Reply-To: <5c4d7c45c9bbf29b7b1b14a0ef1ef3bb12f903cf.1791336930.git.asml.silence@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] io_uring: silent 32-bit truncation of __u64 uaddr and size in io_sqe_buffer_register
--

commit a910d9c1c59f845e8a642099135fc16862f3fe7d
Author: Pavel Begunkov <asml.silence@gmail.com>

io_uring/rsrc: extend buffer update

We need to pass more information to buffer registration than we can fit
into a single struct iovec. This patch allows users to optionally pass
struct io_uring_regbuf_desc, introducing an extended registration format
with a new flags field and types.

> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index da767b34eb553..83a7ad9f5bc78 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c

[ ... ]

> @@ -882,8 +894,13 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
>  	struct io_imu_folio_data data;
>  	bool coalesced = false;
>  
> -	if (!uaddr) {
> -		if (size)
> +	if (desc->type >= __IO_REGBUF_TYPE_MAX)
> +		return ERR_PTR(-EINVAL);
> +	if (!mem_is_zero(&desc->__resv, sizeof(desc->__resv)) || desc->flags)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (desc->type == IO_REGBUF_TYPE_EMPTY) {
> +		if (uaddr || size)

[Severity: Medium]
Does this code silently truncate 64-bit user input on 32-bit platforms?

The new struct io_uring_regbuf_desc defines uaddr and size as __u64:

struct io_uring_regbuf_desc {
...
	__u64 size;
	__u64 uaddr;
};

At the start of io_sqe_buffer_register(), these fields are immediately cast 
to unsigned long and size_t:

static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
						   struct io_uring_regbuf_desc *desc)
{
	unsigned long uaddr = (unsigned long)desc->uaddr;
	size_t size = desc->size;

On 32-bit platforms, this drops the upper 32 bits before any validation
occurs.

If userspace passes 0x100000000 alongside IO_REGBUF_TYPE_EMPTY, the
truncated uaddr and size evaluate to 0.

Would this allow an invalid 64-bit address to pass the emptiness check
and incorrectly bypass the -EFAULT error path?

>  			return ERR_PTR(-EFAULT);
>  		/* remove the buffer without installing a new one */
>  		return NULL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791336930.git.asml.silence@gmail.com?part=10

  reply	other threads:[~2026-10-07  1:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07  1:42 [PATCH v9 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-10-07  1:52   ` sashiko-bot
2026-10-07  1:42 ` [PATCH v9 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-10-07  1:57   ` sashiko-bot
2026-10-07  1:42 ` [PATCH v9 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-10-07  1:59   ` sashiko-bot
2026-10-07  1:42 ` [PATCH v9 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-10-08 12:27   ` Anuj Gupta/Anuj Gupta
2026-10-07  1:42 ` [PATCH v9 06/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 07/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-10-07  2:01   ` sashiko-bot
2026-10-07  1:42 ` [PATCH v9 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-10-07  2:00   ` sashiko-bot
2026-10-07  1:42 ` [PATCH v9 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-10-07  1:51   ` sashiko-bot [this message]
2026-10-07  1:42 ` [PATCH v9 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-10-07  1:42 ` [PATCH v9 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
2026-10-07  1:55   ` sashiko-bot

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=sashiko-outbox-162571@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=asml.silence@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@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