mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiwoo Kim <arpe1618@gmail.com>
To: Alexander Mikhalitsyn <alex@amutable.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Sargun Dhillon <sargun@sargun.me>, Arnd Bergmann <arnd@arndb.de>,
	Jann Horn <jannh@google.com>, Chen Linxuan <me@black-desk.cn>,
	linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pidfd: restrict pidfd_getfd() to the caller's pid namespace
Date: Thu, 19 Nov 2026 22:54:52 +0900	[thread overview]
Message-ID: <20261119135452.990-1-arpe1618@gmail.com> (raw)
In-Reply-To: <3e4103cbcf7b76535e2f957762174515ef00f08d.camel@amutable.com>

On Thu, 2026-11-19 at 14:42 +0100, Alexander Mikhalitsyn wrote:
> It it an interesting point, because pid namespace itself it not a
> security boundary. While user namespace and capabilities are mechanisms
> to manage permissions.

Hi Alex,

thanks for looking at this.

Agreed, and the patch does not try to make it one. I followed the rule
Christian suggested in [1], requiring pid_vnr(pid) != 0 for operations
that grant access to additional resources of the target, which
ee8323fdc827 then applied to the namespace ioctls. pidfd_getfd() hands
out one of the target's open files, so it looked like it belongs to the
same group.

> Currently, you can do something like this on your machine:
[...]
> and this will actually print hello in the Terminal 0, while the process
> doing that lives in nested pid namespace. But this is not a problem
> because this guy is a root:

Right. As far as I can see this also works for an unprivileged task of
the same uid, as long as it can reach the outer task through a procfs
instance of the outer pid namespace. So pidfd_getfd() currently behaves
like procfs here, and the patch would make it stricter than procfs, in
line with the pidfd ioctls and PIDFD_GET_INFO instead.

The case I had in mind is the one Jann described in [2]: a task in a
child pid namespace that gets a pidfd for an outer task over a socket.
When it has no procfs view of the outer task, as in a container with its
own procfs, that pidfd is its only handle to it. There, the ioctls refuse
the pidfd with -EREMOTE, while pidfd_getfd() returns the target's file.

> So please understand me right, I'm not saying that your point is not
> valid, but I'm not sure what was the intention behind pid_getfd() API
> in the first place and we might want to have semantics and model close
> to the one procfs has.

Understood. If pidfd_getfd() should keep following the procfs model, I'm
fine with dropping this patch; the inconsistency would then be on the
ioctl side. I'll leave that to Christian.

> To conclude, it looks like we have a little bit of inconsistencies
> around here :-) [ But please, don't go and change anything in procfs as
> we might break some tricky use-cases like CRIU and SCM_RIGHTS users. ]

No plans to touch procfs.

[1] https://lore.kernel.org/all/20260925-gewischt-auftrag-tierzucht-c153cb3f9f74@brauner/
[2] https://lore.kernel.org/all/CAG48ez1T5-tUHVK_iHsgUtWa-inVdrZxA3E-ZCW0iENJvasKfg@mail.gmail.com/

Thanks,
Jiwoo Kim

      reply	other threads:[~2026-11-19 13:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 15:23 Jiwoo Kim
2026-11-17 16:20 ` Bradley Morgan
2026-11-19 13:42 ` Alexander Mikhalitsyn
2026-11-19 13:54   ` 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=20261119135452.990-1-arpe1618@gmail.com \
    --to=arpe1618@gmail.com \
    --cc=alex@amutable.com \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=jannh@google.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@black-desk.cn \
    --cc=sargun@sargun.me \
    /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®