From: Andreas Hindborg <a.hindborg@kernel.org>
To: peder.bergan@gmail.com, Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>
Cc: "Lorenzo Stoakes" <ljs@kernel.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: alloc: check the length precondition in Vec::from_raw_parts
Date: Mon, 16 Nov 2026 14:07:58 +0100 [thread overview]
Message-ID: <87o6bovs9d.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <20261116-vec-raw-parts-precondition-v1-1-8f633f66b4c1@gmail.com>
"Peder Bergan via B4 Relay" <devnull+peder.bergan.gmail.com@kernel.org>
writes:
> From: Peder Bergan <peder.bergan@gmail.com>
>
> Vec::from_raw_parts() requires length to be no greater than capacity for
> nonzero-sized elements. Check this precondition with
> unsafe_precondition_assert!() before constructing the vector so debug
> builds diagnose invalid raw parts at this boundary.
>
> Keep the check in the nonzero-sized branch because zero-sized vectors
> ignore the capacity argument. Add a KUnit test for reconstructing a
> nonempty zero-sized vector with a zero capacity argument.
>
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1232
> Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Best regards,
Andreas Hindborg
prev parent reply other threads:[~2026-11-16 13:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Cr09eVvg5FecTvFRQ6ONjPHaWg--YJB_fcboFARKLEbwSllbd6wep9zKRdKcsOhp244ll6uaoT7qGtNK7FJgbw==@protonmail.internalid>
2026-11-16 12:53 ` Peder Bergan via B4 Relay
2026-11-16 13:07 ` Andreas Hindborg [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=87o6bovs9d.fsf@t14s.mail-host-address-is-not-set \
--to=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=peder.bergan@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
--cc=vbabka@kernel.org \
--cc=work@onurozkan.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
all inboxes | Powered by JetHome®