summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-09-21 16:15:36 +0200
committerChristian Brauner <brauner@kernel.org>2026-09-22 13:39:34 +0200
commit558cf21f0f2777022cb07ac84977d0c01878942f (patch)
tree049fe00d19d55f87e7f2b5c5b07cfa9853743186 /include
parenta73e3ccf294bf3c5044498fb8aa50010234085d1 (diff)
downloadlinux-next-558cf21f0f2777022cb07ac84977d0c01878942f.tar.gz
linux-next-558cf21f0f2777022cb07ac84977d0c01878942f.zip
file: let dup_fd() drop only close-on-exec descriptors
Add FD_RANGE_CLOEXEC_ONLY. When set dup_fd() leaves everything behind except for fds that are close-on-exec. Without FD_RANGE_EXCEPT the clone loses the close-on-exec descriptors in the range. With it the clone keeps the range and loses the close-on-exec descriptors everywhere else. Descriptors without the flag are carried over either way. Nothing passes the flag yet. Link: https://patch.msgid.link/20260921-work-file-close_range_except-v1-8-c20d0b49270d@kernel.org Reviewed-by: Jann Horn <jannh@google.com> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fdtable.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index d6c6c7a3400d..afdfaad381df 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -104,6 +104,9 @@ int unshare_files(void);
enum fd_range_flags {
/* Leave behind all descriptors outside of the specified range. */
FD_RANGE_EXCEPT = (1U << 0),
+
+ /* Only select descriptors that have close-on-exec set. */
+ FD_RANGE_CLOEXEC_ONLY = (1U << 1),
};
struct fd_range {