History

Merge tag 'threads-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux

Pull thread management updates from Christian Brauner: - A pidfd's fdinfo file currently contains the field "Pid:\t<pid>" where <pid> is the pid of the process in the pid namespace of the procfs instance the fdinfo file for the pidfd was opened in. The fdinfo file has now gained a new "NSpid:\t<ns-pid1>[\t<ns-pid2>[...]]" field which lists the pids of the process in all child pid namespaces provided the pid namespace of the procfs instance it is looked up under has an ancestoral relationship with the pid namespace of the process. If it does not 0 will be shown and no further pid namespaces will be listed. Tests included. (Christian Kellner) - If the process the pidfd references has already exited, print -1 for the Pid and NSpid fields in the pidfd's fdinfo file. Tests included. (me) - Add CLONE_CLEAR_SIGHAND. This lets callers clear all signal handler that are not SIG_DFL or SIG_IGN at process creation time. This originated as a feature request from glibc to improve performance and elimate races in their posix_spawn() implementation. Tests included. (me) - Add support for choosing a specific pid for a process with clone3(). This is the feature which was part of the thread update for v5.4 but after a discussion at LPC in Lisbon we decided to delay it for one more cycle in order to make the interface more generic. This has now done. It is now possible to choose a specific pid in a whole pid namespaces (sub)hierarchy instead of just one pid namespace. In order to choose a specific pid the caller must have CAP_SYS_ADMIN in all owning user namespaces of the target pid namespaces. Tests included. (Adrian Reber) - Test improvements and extensions. (Andrei Vagin, me) * tag 'threads-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: selftests/clone3: skip if clone3() is ENOSYS selftests/clone3: check that all pids are released on error paths selftests/clone3: report a correct number of fails selftests/clone3: flush stdout and stderr before clone3() and _exit() selftests: add tests for clone3() with *set_tid fork: extend clone3() to support setting a PID selftests: add tests for clone3() tests: test CLONE_CLEAR_SIGHAND clone3: add CLONE_CLEAR_SIGHAND pid: use pid_has_task() in pidfd_open() exit: use pid_has_task() in do_wait() pid: use pid_has_task() in __change_pid() test: verify fdinfo for pidfd of reaped process pidfd: check pid has attached task in fdinfo pidfd: add tests for NSpid info in fdinfo pidfd: add NSpid entries to fdinfo

Linus Torvalds committed 6 years ago

Commit 0acefef2 parents 9c91e6a 11fde1618 files · +1308 −58Browse files

Showing the changes to include/linux (3 of 18 files). Show all

Unified · Split

3 files
  1. include/linux/pid.h +6 −1
  2. include/linux/pid_namespace.h +2 −0
  3. include/linux/sched/task.h +3 −0
include/linux/pid.h+6−1
@@ -85,6 +85,10 @@ static inline struct pid *get_pid(struct pid *pid) · 84 unmodified lines
8585
8686 extern void put_pid(struct pid *pid);
8787 extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
88+static inline bool pid_has_task(struct pid *pid, enum pid_type type)
89+{
90+ return !hlist_empty(&pid->tasks[type]);
91+}
8892 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
8993
9094 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
@@ -120,7 +124,8 @@ extern struct pid *find_vpid(int nr); · 29 unmodified lines
120124 extern struct pid *find_get_pid(int nr);
121125 extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
122126
123−extern struct pid *alloc_pid(struct pid_namespace *ns);
127+extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
128+ size_t set_tid_size);
124129 extern void free_pid(struct pid *pid);
125130 extern void disable_pid_allocation(struct pid_namespace *ns);
126131
include/linux/pid_namespace.h+2−0
@@ -12,6 +12,8 @@ · 11 unmodified lines
1212 #include <linux/ns_common.h>
1313 #include <linux/idr.h>
1414
15+/* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
16+#define MAX_PID_NS_LEVEL 32
1517
1618 struct fs_pin;
1719
include/linux/sched/task.h+3−0
@@ -26,6 +26,9 @@ struct kernel_clone_args { · 25 unmodified lines
2626 unsigned long stack;
2727 unsigned long stack_size;
2828 unsigned long tls;
29+ pid_t *set_tid;
30+ /* Number of elements in *set_tid */
31+ size_t set_tid_size;
2932 };
3033
3134 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t