[PATCH 1/2] seccomp: allow addfd to transfer O_PATH descriptors
From: Cong Wang
Date: Thu Sep 24 2026 - 18:31:56 EST
From: Cong Wang <cwang@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxx>
---
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