uapi: expose enum pid_type as enum __kernel_pidtype
Subsystems (3)
PATCH v3 1/1 uapi: expose enum pid_type as enum __kernel_pidtype
Commit 7ac592aa35a684ff ("sched: prctl() core-scheduling interface") made use of enum pid_type in prctl's arg4; however, this type and the associated enumeration definitions are not exposed to userspace. Try to fix that by providing enum __kernel_pidtype and tying in-kernel enum pid_type definitions to it. Note that enum pid_type cannot be exposed as is, since "enum pid_type" is already exists in various projects [1] (notably gcc and strace), and "enum __pid_type" is defined by glibc and uclibc for fcntl(F_SETOWN_EX) owner ID type; there is also __kernel_pid_t, that looks too similar to __kernel_pid_type.
[1] https://codesearch.debian.net/search?q=enum+pid_type
Complements: 7ac592aa35a684ff ("sched: prctl() core-scheduling interface")
---
v3:
- Fixed header guard macro: s/_UAPI_LINUX_PID_H/_UAPI_LINUX_PIDTYPE_H/, as noted by Dmitry Levin.
v2: https://lore.kernel.org/lkml/[email protected]/
- Header file is renamed from pid.h to pidtype.h to avoid collisions
with include/linux/pid.h when included from uapi headers;
- The enum type has renamed from __kernel_pid_type to __kernel_pidtype to avoid possible confusion with __kernel_pid_t.
v1: https://lore.kernel.org/lkml/[email protected]/
--- .../admin-guide/hw-vuln/core-scheduling.rst | 7 ++++--- include/linux/pid.h | 12 +++++++----- include/uapi/linux/pidtype.h | 20 ++++++++++++++++++++ include/uapi/linux/prctl.h | 1 + 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 include/uapi/linux/pidtype.h
Documentation/admin-guide/hw-vuln/core-scheduling.rst +4 -3
@@ -61,9 +61,10 @@ arg3: ``pid`` of the task for which the operation applies. arg4: - ``pid_type`` for which the operation applies. It is of type ``enum pid_type``. - For example, if arg4 is ``PIDTYPE_TGID``, then the operation of this command - will be performed for all tasks in the task group of ``pid``. + ``pid_type`` for which the operation applies. It is of type + ``enum __kernel_pidtype``. For example, if arg4 is ``__PIDTYPE_TGID``, + then the operation of this command will be performed for all tasks + in the task group of ``pid``. arg5: userspace pointer to an unsigned long for storing the cookie returned by
include/linux/pid.h +7 -5
@@ -5,14 +5,16 @@#include <linux/rculist.h> #include <linux/wait.h> #include <linux/refcount.h> +#include <uapi/linux/pidtype.h> enum pid_type { -PIDTYPE_PID , -PIDTYPE_TGID , -PIDTYPE_PGID , -PIDTYPE_SID , -PIDTYPE_MAX , +PIDTYPE_PID = __PIDTYPE_PID, +PIDTYPE_TGID = __PIDTYPE_TGID, +PIDTYPE_PGID = __PIDTYPE_PGID, +PIDTYPE_SID = __PIDTYPE_SID, + +PIDTYPE_MAX = __PIDTYPE_MAX };/*
include/uapi/linux/pidtype.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_PIDTYPE_H +#define _UAPI_LINUX_PIDTYPE_H + +/* +* Type of a process-related ID. So far, it is used only +* for prctl(PR_SCHED_CORE); not to be confused with type field +* of f_owner_ex structure argument of fcntl(F_SETOWN_EX). +*/ +enum __kernel_pidtype +{ + __PIDTYPE_PID, + __PIDTYPE_TGID, + __PIDTYPE_PGID, + __PIDTYPE_SID, + + __PIDTYPE_MAX/* Non-UAPI */ +}; + +#endif /* _UAPI_LINUX_PIDTYPE_H */
include/uapi/linux/prctl.h +1 -0
@@ -3,6 +3,7 @@#define _LINUX_PRCTL_H#include <linux/types.h> +#include <linux/pidtype.h> /* enum __kernel_pidtype */ /* Values to pass as first argument to prctl() */
Signature · 1 line
2.1.4
Quoted 6 lines · Eugene Syromiatnikov
Commit
7ac592aa35a684ff("sched:prctl()core-scheduling interface") made use of enumpid_typein prctl's arg4; however, this type and the associated enumeration definitions are not exposed to userspace. Try to fix that by providing enum__kernel_pidtypeand tying in-kernel enumpid_typedefinitions to it. Note that enumpid_typecannot be exposed as is, since "enumpid_type" is already exists in various projects [1]
Grammar: "enum pid_type" already exists.
Quoted 8 lines
(notably gcc and strace), and "enum
__pid_type" is defined by glibc and uclibc forfcntl(F_SETOWN_EX)owner ID type; there is also__kernel_pid_t, that looks too similar to__kernel_pid_type.[1] https://codesearch.debian.net/search?q=enum+pid_type
Complements:
7ac592aa35a684ff("sched:prctl()core-scheduling interface")Signed-off-by Eugene Syromiatnikov <[email protected]>
Signature · 1 line
ldv