From: "Nicolás Antinori" <nico.antinori.7@gmail.com>
To: "Ivan Tverdokhleb" <mbkchelofficialdev@gmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>
Cc: "Liam R . Howlett" <liam@infradead.org>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
linux-mm@kvack.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2] rust: mm: warn once on invalid VMA range
Date: Thu, 26 Nov 2026 11:10:29 -0300 [thread overview]
Message-ID: <DN57BC2XOPSJ.2UE7DI9RNQUBD@gmail.com> (raw)
In-Reply-To: <20261124153228.134723-1-mbkchelofficialdev@gmail.com>
Hello,
On Tue Nov 24, 2026 at 12:32 PM -03, Ivan Tverdokhleb wrote:
> Use `debug_assert!()` and `pr_warn_once!()` in
> `Vma::zap_vma_range()` to report invalid ranges.
>
> Signed-off-by: Ivan Tverdokhleb <mbkchelofficialdev@gmail.com>
> ---
> Changes in v2:
> - Drop the `warn_once!()` macro and its KUnit test.
> - Use `debug_assert!()` and `pr_warn_once!()` in `Vma::zap_vma_range()` as suggested by Miguel.
>
> rust/kernel/mm/virt.rs | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/mm/virt.rs b/rust/kernel/mm/virt.rs
> index 63eb730b0..1a3a990c9 100644
> --- a/rust/kernel/mm/virt.rs
> +++ b/rust/kernel/mm/virt.rs
> @@ -115,8 +115,9 @@ pub fn end(&self) -> usize {
> #[inline]
> pub fn zap_vma_range(&self, address: usize, size: usize) {
> let (end, did_overflow) = address.overflowing_add(size);
> + debug_assert!(!did_overflow && address >= self.start() && self.end() >= end);
> if did_overflow || address < self.start() || self.end() < end {
> - // TODO: call WARN_ONCE once Rust version of it is added
> + crate::pr_warn_once!("Attempt to zap invalid VMA range\n");
I believe by the comment of Fujita [1], the `pr_warn_once!` should be
guarded by `#[cfg(CONFIG_DEBUG_VM)]`.
Regards,
Nicolás
[1] https://lore.kernel.org/rust-for-linux/20261124.225103.2152350984946270550.tomo@flapping.org/
prev parent reply other threads:[~2026-11-26 14:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261124132609.101657-1-mbkchelofficialdev@gmail.com>
2026-11-24 15:32 ` [PATCH v2] rust: mm: warn once on invalid VMA range Ivan Tverdokhleb
2026-11-26 14:10 ` Nicolás Antinori [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=DN57BC2XOPSJ.2UE7DI9RNQUBD@gmail.com \
--to=nico.antinori.7@gmail.com \
--cc=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=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=lossin@kernel.org \
--cc=mbkchelofficialdev@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--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