public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Gary Guo" <gary@garyguo.net>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Alistair Popple" <apopple@nvidia.com>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>, "Zhi Wang" <zhiw@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	<rust-for-linux@vger.kernel.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] gpu: nova-core: gsp: fix undefined behavior in command queue code
Date: Fri, 27 Mar 2026 15:34:50 +0100	[thread overview]
Message-ID: <DHDN11ONK8AZ.345YPD8NDW5NL@kernel.org> (raw)
In-Reply-To: <20260326-cmdq-ub-fix-v3-1-96af2148ca5c@nvidia.com>

On Thu Mar 26, 2026 at 6:43 AM CET, Alexandre Courbot wrote:
> +        // - Since `data` was created from a valid pointer, both `tail_slice` and `wrap_slice` are
> +        //   pointers to valid arrays.
> +        // - The area starting at `tx` and ending at `rx - 2` modulo `MSGQ_NUM_PAGES`,
> +        //   inclusive, belongs to the driver for writing and is not accessed concurrently by
> +        //   the GSP.
> +        // - The caller holds a reference to `self` for as long as the returned slices are live,
> +        //   meaning the CPU write pointer cannot be advanced and thus that the returned area
> +        //   remains exclusive to the CPU for the duration of the slices.
> +        (unsafe { &mut *tail_slice }, unsafe { &mut *wrap_slice })

I think this does miss the justification for tail_slice and wrap_slice to not
overlap, i.e. don't we need something like:

	- `tail_slice` and `wrap_slice` point to non-overlapping sub-ranges of `data` in all
	  branches (in the `rx <= tx` case, `wrap_slice` ends at `rx - 1` which is strictly less
	  than `tx` where `tail_slice` starts; in the other cases one of the slices is empty),
	  so creating two `&mut` references from them does not violate aliasing rules.

With this considered,

Reviewed-by: Danilo Krummrich <dakr@kernel.org>

  parent reply	other threads:[~2026-03-27 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26  5:43 [PATCH v3] gpu: nova-core: gsp: fix undefined behavior in command queue code Alexandre Courbot
2026-03-27  6:56 ` Alexandre Courbot
2026-03-27 12:23 ` Gary Guo
2026-03-27 14:34 ` Danilo Krummrich [this message]
2026-03-27 20:03 ` kernel test robot
2026-03-28  5:53 ` kernel test robot

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=DHDN11ONK8AZ.345YPD8NDW5NL@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@nvidia.com \
    /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