[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 2 Feb 2024 07:36:21 -0800
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.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>,
Peter Zijlstra <peterz@...radead.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
Joel Fernandes <joel@...lfernandes.org>,
Carlos Llamas <cmllamas@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Dan Williams <dan.j.williams@...el.com>,
Kees Cook <keescook@...omium.org>,
Matthew Wilcox <willy@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>, Daniel Xu <dxu@...uu.xyz>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v4 7/9] rust: file: add `Kuid` wrapper
On Fri, Feb 02, 2024 at 10:55:41AM +0000, Alice Ryhl wrote:
> + /// Returns the given task's pid in the current pid namespace.
> + pub fn pid_in_current_ns(&self) -> Pid {
> + let current = Task::current_raw();
> + // SAFETY: Calling `task_active_pid_ns` with the current task is always safe.
> + let namespace = unsafe { bindings::task_active_pid_ns(current) };
> + // SAFETY: We know that `self.0.get()` is valid by the type invariant, and the namespace
> + // pointer is not dangling since it points at this task's namespace.
> + unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) }
> + }
pids are reference counted in the kernel, how does this deal with that?
Are they just ignored somehow? Where is the reference count given back?
thanks,
greg k-h
Powered by blists - more mailing lists