Skip to content

Commit a4c746f

Browse files
committed
uapi/fcntl: mark range as reserved
Mark the range from -10000 to -40000 as a range reserved for special in-kernel values. Move the PIDFD_SELF_*/PIDFD_THREAD_* sentinels over so all the special values are in one place. Link: https://lore.kernel.org/20250624-work-pidfs-fhandle-v2-6-d02a04858fe3@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 1c54843 commit a4c746f

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

include/uapi/linux/fcntl.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,26 @@
9090
#define DN_ATTRIB 0x00000020 /* File changed attibutes */
9191
#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
9292

93+
/* Reserved kernel ranges [-100], [-10000, -40000]. */
9394
#define AT_FDCWD -100 /* Special value for dirfd used to
9495
indicate openat should use the
9596
current working directory. */
9697

98+
/*
99+
* The concept of process and threads in userland and the kernel is a confusing
100+
* one - within the kernel every thread is a 'task' with its own individual PID,
101+
* however from userland's point of view threads are grouped by a single PID,
102+
* which is that of the 'thread group leader', typically the first thread
103+
* spawned.
104+
*
105+
* To cut the Gideon knot, for internal kernel usage, we refer to
106+
* PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
107+
* perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
108+
* group leader...
109+
*/
110+
#define PIDFD_SELF_THREAD -10000 /* Current thread. */
111+
#define PIDFD_SELF_THREAD_GROUP -20000 /* Current thread group leader. */
112+
97113

98114
/* Generic flags for the *at(2) family of syscalls. */
99115

include/uapi/linux/pidfd.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,6 @@
4242
#define PIDFD_COREDUMP_USER (1U << 2) /* coredump was done as the user. */
4343
#define PIDFD_COREDUMP_ROOT (1U << 3) /* coredump was done as root. */
4444

45-
/*
46-
* The concept of process and threads in userland and the kernel is a confusing
47-
* one - within the kernel every thread is a 'task' with its own individual PID,
48-
* however from userland's point of view threads are grouped by a single PID,
49-
* which is that of the 'thread group leader', typically the first thread
50-
* spawned.
51-
*
52-
* To cut the Gideon knot, for internal kernel usage, we refer to
53-
* PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
54-
* perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
55-
* group leader...
56-
*/
57-
#define PIDFD_SELF_THREAD -10000 /* Current thread. */
58-
#define PIDFD_SELF_THREAD_GROUP -20000 /* Current thread group leader. */
59-
6045
/*
6146
* ...and for userland we make life simpler - PIDFD_SELF refers to the current
6247
* thread, PIDFD_SELF_PROCESS refers to the process thread group leader.

0 commit comments

Comments
 (0)