All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sidong Yang <sidong.yang@furiosa.ai>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Caleb Sander Mateos <csander@purestorage.com>,
	Benno Lossin <lossin@kernel.org>, Miguel Ojeda <ojeda@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	io-uring@vger.kernel.org
Subject: Re: [PATCH v4 2/5] io_uring/cmd: zero-init pdu in io_uring_cmd_prep() to avoid UB
Date: Sat, 11 Apr 2026 12:11:56 +0000	[thread overview]
Message-ID: <ado6jBVkfs8JNmO-@sidong> (raw)
In-Reply-To: <2026040908-certainly-dealmaker-5530@gregkh>

On Thu, Apr 09, 2026 at 07:27:18AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Apr 08, 2026 at 01:59:59PM +0000, Sidong Yang wrote:
> > The pdu field in io_uring_cmd may contain stale data when a request
> > object is recycled from the slab cache. Accessing uninitialized or
> > garbage memory can lead to undefined behavior in users of the pdu.
> 
> Who accesses this?  If that happens, then yes this is a problem, but if
> not, then there's no need for this change, right (i.e. either this is a
> bug to be fixed now or not.)

Hi Greg,

Thank you for the review.

You are right, this patch is not fixing an existing bug.  I added it
because the Rust abstraction provides read_pdu() which reads from the
PDU, and without zero-initialization a Rust caller could observe stale
data from a recycled slab object.  While "stale but valid" might be
harmless in C, in Rust we want to guarantee a clean initial state.

That said, I realize this is a C-side change that is only motivated by
the Rust side.  I will drop this patch from the series and handle
zero-initialization within the Rust miscdevice vtable wrapper instead
(which the current code already does).

Thanks,
Sidong

> 
> > Ensure the pdu buffer is cleared during io_uring_cmd_prep() so that
> > each command starts from a well-defined state. This avoids exposing
> > uninitialized memory and prevents potential misinterpretation of data
> > from previous requests.
> 
> Where is the memory exposed and who misinterprets it?
> 
> > No functional change is intended other than guaranteeing that pdu is
> > always zero-initialized before use.
> 
> This strongly implies that this is not needed at all.
> 
> thanks,
> 
> greg k-h

  reply	other threads:[~2026-04-11 12:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08 13:59 [PATCH v4 0/5] Rust io_uring command abstraction for miscdevice Sidong Yang
2026-04-08 13:59 ` [PATCH v4 1/5] rust: bindings: add io_uring headers in bindings_helper.h Sidong Yang
2026-04-08 14:31   ` Miguel Ojeda
2026-04-09  1:20     ` Sidong Yang
2026-04-08 13:59 ` [PATCH v4 2/5] io_uring/cmd: zero-init pdu in io_uring_cmd_prep() to avoid UB Sidong Yang
2026-04-09  5:27   ` Greg Kroah-Hartman
2026-04-11 12:11     ` Sidong Yang [this message]
2026-04-08 14:00 ` [PATCH v4 3/5] rust: io_uring: introduce rust abstraction for io-uring cmd Sidong Yang
2026-04-08 14:00 ` [PATCH v4 4/5] rust: miscdevice: Add `uring_cmd` support Sidong Yang
2026-04-08 14:00 ` [PATCH v4 5/5] samples: rust: Add `uring_cmd` example to `rust_misc_device` Sidong Yang
2026-04-09  5:25 ` [PATCH v4 0/5] Rust io_uring command abstraction for miscdevice Greg Kroah-Hartman
2026-04-11 12:16   ` Sidong Yang
2026-04-11 12:27     ` Greg Kroah-Hartman
2026-04-14 15:36       ` Sidong Yang
2026-04-14 16:20         ` Greg Kroah-Hartman

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=ado6jBVkfs8JNmO-@sidong \
    --to=sidong.yang@furiosa.ai \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=daniel.almeida@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.