[PATCH v17 05/10] rust: page: convert to `Ownable`

Andreas Hindborg a.hindborg at kernel.org
Tue Jun 23 13:12:33 UTC 2026


Alice Ryhl <aliceryhl at google.com> writes:

> On Thu, Jun 04, 2026 at 10:11:17PM +0200, Andreas Hindborg wrote:
>> From: Asahi Lina <lina at asahilina.net>
>> 
>> This allows Page references to be returned as borrowed references,
>> without necessarily owning the struct page.
>> 
>> Signed-off-by: Asahi Lina <lina at asahilina.net>
>> [ Andreas: Fix formatting and add a safety comment. ]
>> Signed-off-by: Andreas Hindborg <a.hindborg at kernel.org>
>> ---
>>  rust/kernel/page.rs | 38 +++++++++++++++++++++++++-------------
>>  1 file changed, 25 insertions(+), 13 deletions(-)
>> 
>> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
>> index 3bdcee0e16a8..844c75e54134 100644
>> --- a/rust/kernel/page.rs
>> +++ b/rust/kernel/page.rs
>> @@ -10,6 +10,11 @@
>>      bindings,
>>      error::code::*,
>>      error::Result,
>> +    types::{
>> +        Opaque,
>> +        Ownable,
>> +        Owned, //
>> +    },
>>      uaccess::UserSliceReader, //
>>  };
>>  use core::{
>> @@ -105,7 +110,7 @@ pub const fn page_align(addr: usize) -> Option<usize> {
>>  ///
>>  /// [`VBox`]: kernel::alloc::VBox
>>  /// [`Vmalloc`]: kernel::alloc::allocator::Vmalloc
>> -pub struct BorrowedPage<'a>(ManuallyDrop<Page>, PhantomData<&'a Page>);
>> +pub struct BorrowedPage<'a>(ManuallyDrop<NonNull<Page>>, PhantomData<&'a Page>);
>
> BorrowedPage<'a> is no longer needed because it's just &Page.

I'll add some cleaning then.


Best regards,
Andreas Hindborg






More information about the Linux-security-module-archive mailing list