summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-09-21 16:15:36 +0200
committerChristian Brauner <brauner@kernel.org>2026-10-05 13:02:40 +0200
commit4587f99cc2c87079167b18e284f64b66cafade76 (patch)
treea43b69e414d43d00f90ea9297d8806a0809db0e4 /include/linux
parent4ee7588bbbfa67ebea345e1e36fbb370872c1e53 (diff)
downloadlinux-4587f99cc2c87079167b18e284f64b66cafade76.tar.gz
linux-4587f99cc2c87079167b18e284f64b66cafade76.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/linux')
-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 {