From: jongan.kim@lge.com
To: jongan.kim@lge.com, aliceryhl@google.com, arve@android.com,
brauner@kernel.org, cmllamas@google.com, tkjos@android.com
Cc: a.hindborg@kernel.org, bjorn3_gh@protonmail.com,
boqun.feng@gmail.com, dakr@kernel.org,
daniel.almeida@collabora.com, gary@garyguo.net,
gregkh@linuxfoundation.org, heesu0025.kim@lge.com,
ht.hong@lge.com, jungsu.hwang@lge.com, kernel-team@android.com,
linux-kernel@vger.kernel.org, lossin@kernel.org,
ojeda@kernel.org, rust-for-linux@vger.kernel.org,
sanghun.lee@lge.com, seulgi.lee@lge.com, sunghoon.kim@lge.com,
tamird@gmail.com, tmgross@umich.edu, viresh.kumar@linaro.org,
vitaly.wool@konsulko.se, yury.norov@gmail.com
Subject: Re: [PATCH v4 1/3] binder: fix PID namespace collision for freeze operation
Date: Wed, 11 Feb 2026 19:17:30 +0900 [thread overview]
Message-ID: <20260211101730.5654-1-jongan.kim@lge.com> (raw)
In-Reply-To: <20260206085336.32819-2-jongan.kim@lge.com>
On Fri, Feb 06 2026 at 17:53:34PM +0900, jongan.kim@lge.com wrote:
> From: JongAn Kim <jongan.kim@lge.com>
>
> Currently, when a freeze is attempted from a non-init PID namespace,
> there is a possibility that the wrong process in the init namespace
> may be frozen due to PID collision across namespaces.
>
> For example, if a container with PID namespace has a process with
> PID 100 (which maps to PID 5000 in init namespace), attempting to
> freeze PID 100 from the container could incorrectly match a different
> process with PID 100 in the init namespace.
>
> This patch fixes the issue by:
> 1. Using find_get_task_by_vpid() to get task_struct from caller's namespace
> 2. Comparing task_struct pointers directly instead of PID values
> 3. This ensures we match the exact task regardless of PID namespace
>
> This change ensures correct PID handling when binder freeze occurs in
> non-init PID namespace.
>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Link: https://lore.kernel.org/lkml/aXs5Y3xAFKyZr6nd@google.com/
> Signed-off-by: JongAn Kim <jongan.kim@lge.com>
> ---
> v3 -> v4 :
> - change subject name more clearly
> - comapre task_struct pointers directly instead of PID
>
> v2 -> v3 : change to use task->tgid instead of task_tgid_nr_ns()
>
> drivers/android/binder.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 535fc881c8da..6d68f98a18db 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5717,13 +5717,18 @@ static int binder_ioctl_get_freezer_info(
> struct binder_proc *target_proc;
> bool found = false;
> __u32 txns_pending;
> + struct task_struct *task;
>
> info->sync_recv = 0;
> info->async_recv = 0;
>
> + task = find_get_task_by_vpid(info->pid);
> + if (!task)
> + return -ESRCH;
> +
> mutex_lock(&binder_procs_lock);
> hlist_for_each_entry(target_proc, &binder_procs, proc_node) {
> - if (target_proc->pid == info->pid) {
> + if (target_proc->tsk == task) {
> found = true;
> binder_inner_proc_lock(target_proc);
> txns_pending = binder_txns_pending_ilocked(target_proc);
> @@ -5734,6 +5739,7 @@ static int binder_ioctl_get_freezer_info(
> }
> }
> mutex_unlock(&binder_procs_lock);
> + put_task_struct(task);
>
> if (!found)
> return -EINVAL;
> @@ -5869,6 +5875,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> struct binder_freeze_info info;
> struct binder_proc **target_procs = NULL, *target_proc;
> int target_procs_count = 0, i = 0;
> + struct task_struct *task;
>
> ret = 0;
>
> @@ -5877,14 +5884,21 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> goto err;
> }
>
> + task = find_get_task_by_vpid(info.pid);
> + if (!task) {
> + ret = -ESRCH;
> + goto err;
> + }
> +
> mutex_lock(&binder_procs_lock);
> hlist_for_each_entry(target_proc, &binder_procs, proc_node) {
> - if (target_proc->pid == info.pid)
> + if (target_proc->tsk == task)
> target_procs_count++;
> }
>
> if (target_procs_count == 0) {
> mutex_unlock(&binder_procs_lock);
> + put_task_struct(task);
> ret = -EINVAL;
> goto err;
> }
> @@ -5895,12 +5909,13 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>
> if (!target_procs) {
> mutex_unlock(&binder_procs_lock);
> + put_task_struct(task);
> ret = -ENOMEM;
> goto err;
> }
>
> hlist_for_each_entry(target_proc, &binder_procs, proc_node) {
> - if (target_proc->pid != info.pid)
> + if (target_proc->tsk != task)
> continue;
>
> binder_inner_proc_lock(target_proc);
> @@ -5910,6 +5925,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> target_procs[i++] = target_proc;
> }
> mutex_unlock(&binder_procs_lock);
> + put_task_struct(task);
>
> for (i = 0; i < target_procs_count; i++) {
> if (ret >= 0)gg
Dear Alice and Android Driver Maintainers,
I would appreciate it if you could review patch v4.
Thank you for your time and effort.
Best regards,
Jong An Kim
next prev parent reply other threads:[~2026-02-11 10:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 8:53 [PATCH v4 0/3] binder: handle PID namespace conversion " jongan.kim
2026-02-06 8:53 ` [PATCH v4 1/3] binder: fix PID namespace collision " jongan.kim
2026-02-11 10:17 ` jongan.kim [this message]
2026-02-11 10:17 ` jongan.kim
2026-02-11 11:13 ` Greg KH
2026-02-12 1:05 ` jongan.kim
2026-02-06 8:53 ` [PATCH v4 2/3] rust: pid: add Pid abstraction and init_ns helper jongan.kim
2026-02-11 10:42 ` Alice Ryhl
2026-02-13 5:15 ` jongan.kim
2026-02-06 8:53 ` [PATCH v4 3/3] rust_binder: fix PID namespace collision for freeze operation jongan.kim
2026-02-06 16:20 ` Gary Guo
2026-02-09 5:21 ` heesu0025.kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260211101730.5654-1-jongan.kim@lge.com \
--to=jongan.kim@lge.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=heesu0025.kim@lge.com \
--cc=ht.hong@lge.com \
--cc=jungsu.hwang@lge.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sanghun.lee@lge.com \
--cc=seulgi.lee@lge.com \
--cc=sunghoon.kim@lge.com \
--cc=tamird@gmail.com \
--cc=tkjos@android.com \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.org \
--cc=vitaly.wool@konsulko.se \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®