uapi/fcntl: mark range as reserved
authorChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 13:48:42 +0000 (15:48 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 13:50:06 +0000 (15:50 +0200)
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>
include/uapi/linux/fcntl.h
include/uapi/linux/pidfd.h

index a15ac2fa4b202fa0f9d8350e347dbc2560a1c08b..ed02d8ae06673884941de06e6ace17d46eec7aad 100644 (file)
 #define DN_ATTRIB      0x00000020      /* File changed attibutes */
 #define DN_MULTISHOT   0x80000000      /* Don't remove notifier */
 
+/* Reserved kernel ranges [-100], [-10000, -40000]. */
 #define AT_FDCWD               -100    /* Special value for dirfd used to
                                           indicate openat should use the
                                           current working directory. */
 
+/*
+ * The concept of process and threads in userland and the kernel is a confusing
+ * one - within the kernel every thread is a 'task' with its own individual PID,
+ * however from userland's point of view threads are grouped by a single PID,
+ * which is that of the 'thread group leader', typically the first thread
+ * spawned.
+ *
+ * To cut the Gideon knot, for internal kernel usage, we refer to
+ * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
+ * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
+ * group leader...
+ */
+#define PIDFD_SELF_THREAD              -10000 /* Current thread. */
+#define PIDFD_SELF_THREAD_GROUP                -20000 /* Current thread group leader. */
+
 
 /* Generic flags for the *at(2) family of syscalls. */
 
index c27a4e238e4bead8723a3ecf4affe4cead66ed9e..957db425d459a1c67ffa21c2e762bebca23492ff 100644 (file)
 #define PIDFD_COREDUMP_USER    (1U << 2) /* coredump was done as the user. */
 #define PIDFD_COREDUMP_ROOT    (1U << 3) /* coredump was done as root. */
 
-/*
- * The concept of process and threads in userland and the kernel is a confusing
- * one - within the kernel every thread is a 'task' with its own individual PID,
- * however from userland's point of view threads are grouped by a single PID,
- * which is that of the 'thread group leader', typically the first thread
- * spawned.
- *
- * To cut the Gideon knot, for internal kernel usage, we refer to
- * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
- * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
- * group leader...
- */
-#define PIDFD_SELF_THREAD              -10000 /* Current thread. */
-#define PIDFD_SELF_THREAD_GROUP                -20000 /* Current thread group leader. */
-
 /*
  * ...and for userland we make life simpler - PIDFD_SELF refers to the current
  * thread, PIDFD_SELF_PROCESS refers to the process thread group leader.