Re: [PATCH v2 3/3] rust_binder: handle PID namespace conversion for freeze operation
From: Alice Ryhl
Date: Thu Jan 29 2026 - 05:51:59 EST
On Thu, Jan 29, 2026 at 05:41:19PM +0900, jongan.kim@xxxxxxx wrote:
> From: HeeSu Kim <heesu0025.kim@xxxxxxx>
>
> Port PID namespace conversion logic from C binder to the Rust
> implementation.
>
> Without namespace conversion, freeze operations from non-init namespaces
> can match wrong processes due to PID collision. This adds proper
> conversion to ensure freeze operations target the correct process.
>
> Signed-off-by: HeeSu Kim <heesu0025.kim@xxxxxxx>
Overall looks good, thanks!
> +/// Convert a PID from the current namespace to the global (init) namespace.
> +fn convert_to_init_ns_tgid(pid: u32) -> Result<i32> {
Let's use the typedef task::Pid (of bindings::pid_t) here, so you can
avoid the `init_ns_pid as _` cast below.
> + let current = kernel::current!();
> + let init_ns = init_pid_ns();
> +
> + if current.active_pid_ns().map(|ns| ns.as_ptr()) == Some(init_ns.as_ptr()) {
I'd like to avoid comparing raw pointers for this. Perhaps we should just provide
an implementation of `==` for PidNamespace that compares the address?
Alice