From: Cong Wang <xiyou.wangcong@gmail.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Kees Cook <kees@kernel.org>,
linux-kernel@vger.kernel.org, Will Drewry <wad@chromium.org>,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH 1/2] seccomp: allow addfd to transfer O_PATH descriptors
Date: Thu, 24 Sep 2026 15:30:16 -0700 [thread overview]
Message-ID: <20260924223018.564548-2-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20260924223018.564548-1-xiyou.wangcong@gmail.com>
From: Cong Wang <cwang@multikernel.io>
SECCOMP_IOCTL_NOTIF_ADDFD uses fget() to acquire the supervisor's
source descriptor. fget() rejects FMODE_PATH files, so injecting an
O_PATH descriptor fails with EBADF before the receiving task can
install it.
Use fget_raw() to acquire the source file. This takes the same
reference while allowing FMODE_PATH. The existing receive_fd() and
receive_fd_replace() paths retain their security_file_receive()
checks and preserve the file's O_PATH semantics.
Fixes: 7cf97b125455 ("seccomp: Introduce addfd ioctl to seccomp user notifier")
Assisted-by: Codex:gpt-6
Signed-off-by: Cong Wang <cwang@multikernel.io>
---
kernel/seccomp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 86cf4460d69e..4ce59be6d89f 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -1735,7 +1735,7 @@ static long seccomp_notify_addfd(struct seccomp_filter *filter,
if (addfd.newfd && !(addfd.flags & SECCOMP_ADDFD_FLAG_SETFD))
return -EINVAL;
- kaddfd.file = fget(addfd.srcfd);
+ kaddfd.file = fget_raw(addfd.srcfd);
if (!kaddfd.file)
return -EBADF;
--
2.43.0
next prev parent reply other threads:[~2026-09-24 22:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 22:30 [PATCH 0/2] seccomp: support O_PATH descriptors in addfd Cong Wang
2026-09-24 22:30 ` Cong Wang [this message]
2026-09-24 22:30 ` [PATCH 2/2] selftests/seccomp: test addfd with an O_PATH descriptor Cong Wang
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=20260924223018.564548-2-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=brauner@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=wad@chromium.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 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®