lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250131161549.306073-1-trintaeoitogc@gmail.com>
Date: Fri, 31 Jan 2025 13:15:49 -0300
From: Guilherme Giacomo Simoes <trintaeoitogc@...il.com>
To: aliceryhl@...gle.com
Cc: a.hindborg@...nel.org,
	alex.gaynor@...il.com,
	benno.lossin@...ton.me,
	bjorn3_gh@...tonmail.com,
	boqun.feng@...il.com,
	gary@...yguo.net,
	linux-kernel@...r.kernel.org,
	longman@...hat.com,
	mingo@...hat.com,
	ojeda@...nel.org,
	peterz@...radead.org,
	rust-for-linux@...r.kernel.org,
	tmgross@...ch.edu,
	trintaeoitogc@...il.com,
	will@...nel.org
Subject: Re: [PATCH] rust: sync: create the `get_mut()` function

Alice Ryhl <aliceryhl@...gle.com> wrotes:
> As far as I can tell, it's impossible to call this function because
> you cannot obtain a bare mutable reference to a pinned value.
So, I can call this function make anything like: 

```
use kernel::sync::{new_mutex, Mutex};

struct Inner {
    a: u32,
}

#[pin_data]
struct Example {
    #[pin]
    d: Mutex<Inner>,
}

impl Example {
    fn new() -> impl PinInit<Self> {
        pin_init!(Self {
            // This new_mutex! can be anothers locks like new_spinlock!()
            d <- new_mutex!(Inner { a: 20 })
        })
    }
}

let mut pin = KBox::pin_init(Example::new(), GFP_KERNEL)?;
let mut_pin = pin.as_mut();

let data = unsafe { Pin::get_unchecked_mut(mut_pin).d.get_mut() };
assert_eq!(data.a, 20);
```

Thanks,
Guilherme

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ