Linux filesystem development
 help / color / mirror / Atom feed
From: Jiwoo Kim <arpe1618@gmail.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Jann Horn <jannh@google.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Chen Linxuan <me@black-desk.cn>,
	linux-mm@kvack.org
Subject: Re: [PATCH 0/3] pidfd: use one helper for pid namespace visibility checks
Date: Fri, 20 Nov 2026 23:33:49 +0900	[thread overview]
Message-ID: <20261120143349.979-1-arpe1618@gmail.com> (raw)
In-Reply-To: <20261120-work-pidfd-pidns_visible-v1-0-0e82d08469ae@kernel.org>

On Fri, Nov 20, 2026 at 02:42:08PM +0100, Christian Brauner wrote:
> The pidfd api checks in a bunch of places whether the target of a pidfd
> is visible in the caller's pid namespace. pidfs has
> pid_in_current_pidns() for PIDFD_GET_INFO and the namespace and task
> path ioctls. The pidfs file handle lookup open-codes pid_vnr() and
> pidfd_getfd() does the same since Jiwoo's fix [1]. pidfd_send_signal()
> walks the pid namespace hierarchy in its own access_pidfd_pidns().
> Yuck, unify it.

Thanks for picking up the fix and for the follow-up.

I went through the three patches. The equivalence argument in 2/3
holds: alloc_pid() fills pid->numbers[i].ns with the ancestor at level
i, so the ->parent walk in access_pidfd_pidns() can only meet the
caller's namespace at pid->numbers[active->level].

One nit on the 3/3 changelog: process_madvise() on another process
also needs CAP_SYS_NICE and only accepts the non-destructive hints, so
there the cross-namespace case already needs a privileged caller.
process_mrelease() is the one without a permission check.

I also ran the series in a QEMU guest, on a v7.4-rc3 based tree with
the fix applied, as uid 1000 without capabilities:

- caller in a child pid namespace, same user namespace, pidfd for a
  task outside of it: process_madvise(MADV_COLD) and process_mrelease()
  now fail with -EREMOTE (before: -EPERM and -EINVAL),
  pidfd_send_signal() still fails with -EINVAL and pidfd_getfd() with
  -EREMOTE;
- caller in the target's pid namespace: all four return what they
  returned before.

The review and the test were done with the help of an AI coding
assistant.

For the series:

Reviewed-by: Jiwoo Kim <arpe1618@gmail.com>
Tested-by: Jiwoo Kim <arpe1618@gmail.com>

      parent reply	other threads:[~2026-11-20 14:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 13:42 [PATCH 0/3] pidfd: use one helper for pid namespace visibility checks Christian Brauner
2026-11-20 13:42 ` [PATCH 1/3] pid: move pid_in_current_pidns() into kernel/pid.c Christian Brauner
2026-11-20 14:10   ` Alexander Mikhalitsyn
2026-11-20 13:42 ` [PATCH 2/3] pidfd: convert remaining visibility checks to pid_in_current_pidns() Christian Brauner
2026-11-20 14:10   ` Alexander Mikhalitsyn
2026-11-20 13:42 ` [PATCH 3/3] pidfd: restrict pidfd_get_task() to the caller's pid namespace Christian Brauner
2026-11-20 14:33 ` Jiwoo Kim [this message]

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=20261120143349.979-1-arpe1618@gmail.com \
    --to=arpe1618@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=me@black-desk.cn \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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