[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGSQo00138fombiueBM-4-OF15afzx3U63Uu17K_wvh9mkFAPg@mail.gmail.com>
Date: Mon, 12 Aug 2024 16:32:23 -0700
From: Matthew Maurer <mmaurer@...gle.com>
To: dvyukov@...gle.com, ojeda@...nel.org,
Andrey Ryabinin <ryabinin.a.a@...il.com>, Andrew Morton <akpm@...ux-foundation.org>,
Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>
Cc: aliceryhl@...gle.com, samitolvanen@...gle.com,
Alexander Potapenko <glider@...gle.com>, Andrey Konovalov <andreyknvl@...il.com>,
Vincenzo Frascino <vincenzo.frascino@....com>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...sung.com>,
linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com, linux-mm@...ck.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v2 3/3] kasan: rust: Add KASAN smoke test via UAF
> diff --git a/mm/kasan/kasan_test_rust.rs b/mm/kasan/kasan_test_rust.rs
> new file mode 100644
> index 000000000000..6f4b43ea488c
> --- /dev/null
> +++ b/mm/kasan/kasan_test_rust.rs
> @@ -0,0 +1,17 @@
Realized right after sending there should be
// SPDX-License-Identifier: GPL-2.0
here. It should be added before merging, but not re-sending to avoid spam.
> +//! Helper crate for KASAN testing
> +//! Provides behavior to check the sanitization of Rust code.
> +use kernel::prelude::*;
> +use core::ptr::addr_of_mut;
> +
> +/// Trivial UAF - allocate a big vector, grab a pointer partway through,
> +/// drop the vector, and touch it.
> +#[no_mangle]
> +pub extern "C" fn kasan_test_rust_uaf() -> u8 {
> + let mut v: Vec<u8> = Vec::new();
> + for _ in 0..4096 {
> + v.push(0x42, GFP_KERNEL).unwrap();
> + }
> + let ptr: *mut u8 = addr_of_mut!(v[2048]);
> + drop(v);
> + unsafe { *ptr }
> +}
> --
> 2.46.0.76.ge559c4bf1a-goog
>
Powered by blists - more mailing lists