* [PATCH v2] rust: mm: warn once on invalid VMA range
[not found] <20261124132609.101657-1-mbkchelofficialdev@gmail.com>
@ 2026-11-24 15:32 ` Ivan Tverdokhleb
2026-11-26 14:10 ` Nicolás Antinori
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Tverdokhleb @ 2026-11-24 15:32 UTC (permalink / raw)
To: Alice Ryhl, Miguel Ojeda
Cc: Liam R . Howlett, FUJITA Tomonori, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-mm, rust-for-linux,
Ivan Tverdokhleb
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");
return;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] rust: mm: warn once on invalid VMA range
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
0 siblings, 0 replies; 2+ messages in thread
From: Nicolás Antinori @ 2026-11-26 14:10 UTC (permalink / raw)
To: Ivan Tverdokhleb, Alice Ryhl, Miguel Ojeda
Cc: Liam R . Howlett, FUJITA Tomonori, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-mm, rust-for-linux
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox