[PATCH v10 7/8] rust: file: add `Kuid` wrapper

Alice Ryhl aliceryhl at google.com
Mon Sep 23 09:13:56 UTC 2024


On Mon, Sep 16, 2024 at 12:02 AM Gary Guo <gary at garyguo.net> wrote:
>
> On Sun, 15 Sep 2024 14:31:33 +0000
> Alice Ryhl <aliceryhl at google.com> wrote:
> > +    /// Returns the given task's pid in the current pid namespace.
> > +    pub fn pid_in_current_ns(&self) -> Pid {
> > +        // SAFETY: We know that `self.0.get()` is valid by the type invariant, and passing a null
> > +        // pointer as the namespace is correct for using the current namespace.
> > +        unsafe { bindings::task_tgid_nr_ns(self.0.get(), ptr::null_mut()) }
>
> Do we want to rely on the behaviour of `task_tgid_nr_ns` with null
> pointer as namespace, or use `task_tgid_vnr`?

Hmm. Looks like C Binder actually does:
trd->sender_pid = task_tgid_nr_ns(sender, task_active_pid_ns(current));

Not sure why I'm using a null pointer here.

Alice



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