All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bradley Morgan <bradley.morgan@linux.dev>
To: devnexen@gmail.com
Cc: brauner@kernel.org, josh@joshtriplett.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, oleg@redhat.com,
	shuah@kernel.org
Subject: Re: [RFC PATCH 0/2] pidfd: add PIDFD_GETFD_NO_SELF
Date: Mon, 30 Nov 2026 15:50:35 +0000	[thread overview]
Message-ID: <417D9E47-9FE7-452B-8F62-55A8B67F020D@linux.dev> (raw)
In-Reply-To: <20261129212732.805592-1-devnexen@gmail.com>

On 29 November 2026 21:27:30 GMT, David Carlier <devnexen@gmail.com> wrote:
>pidfd_getfd() on a task that shares the caller's fd table duplicates one
>of the caller's own descriptors. This is the only case that forces a
>pidfd_getfd() wrapper in the Rust standard library to be unsafe [1].
>
>Add PIDFD_GETFD_NO_SELF, which makes pidfd_getfd() fail with ELOOP when
>the target shares the caller's fd table: the caller, its threads, or a
>CLONE_FILES task that has not unshared. The check is on the fd table
>rather than the thread group. A tgid comparison in userspace misses
>CLONE_FILES, and kcmp(KCMP_FILES) depends on CONFIG_KCMP.
>
>ELOOP is open to change. It only has to differ from EINVAL so that
>userspace can tell an old kernel from a refused target.
>
>Suggested by Josh Triplett. Tested on vfs.all (7.4-rc4) in a VM with
>the added selftests. An LLM helped with the analysis and generated the
>selftests.

Looks ok, thanks

Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>


>[1] https://github.com/rust-lang/libs-team/issues/939
>
>David Carlier (2):
>  pidfd: add PIDFD_GETFD_NO_SELF to pidfd_getfd()
>  selftests/pidfd: test PIDFD_GETFD_NO_SELF
>
> include/uapi/linux/pidfd.h                    |   3 +
> kernel/pid.c                                  |  29 ++-
> tools/testing/selftests/pidfd/pidfd.h         |   4 +
> .../selftests/pidfd/pidfd_getfd_test.c        | 177 +++++++++++++++++-
> 4 files changed, 205 insertions(+), 8 deletions(-)
>
>
>base-commit: 84fb6f8a1ba91eee3ffe6aa519686fce851a0e42
>

--- Thanks!

      parent reply	other threads:[~2026-11-30 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 21:27 [RFC PATCH 0/2] pidfd: add PIDFD_GETFD_NO_SELF David Carlier
2026-11-29 21:27 ` [RFC PATCH 1/2] pidfd: add PIDFD_GETFD_NO_SELF to pidfd_getfd() David Carlier
2026-11-29 21:27 ` [RFC PATCH 2/2] selftests/pidfd: test PIDFD_GETFD_NO_SELF David Carlier
2026-11-29 23:49 ` [RFC PATCH 0/2] pidfd: add PIDFD_GETFD_NO_SELF Josh Triplett
2026-11-30 15:50 ` Bradley Morgan [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=417D9E47-9FE7-452B-8F62-55A8B67F020D@linux.dev \
    --to=bradley.morgan@linux.dev \
    --cc=brauner@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=shuah@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.