]>
Commit | Line | Data |
---|---|---|
672e27e4 MK |
1 | .\" Copyright (c) 2015 by Michael Kerrisk <mtk.manpages@gmail.com> |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
672e27e4 MK |
4 | .\" |
5 | .\" | |
4c1c5274 | 6 | .TH nptl 7 (date) "Linux man-pages (unreleased)" |
672e27e4 MK |
7 | .SH NAME |
8 | nptl \- Native POSIX Threads Library | |
9 | .SH DESCRIPTION | |
10 | NPTL (Native POSIX Threads Library) | |
11 | is the GNU C library POSIX threads implementation that is used on modern | |
12 | Linux systems. | |
13 | .\" | |
14 | .SS NPTL and signals | |
15 | NPTL makes internal use of the first two real-time signals | |
16 | (signal numbers 32 and 33). | |
1f08fc80 | 17 | One of these signals is used to support thread cancelation and POSIX timers |
c99652b7 MK |
18 | (see |
19 | .BR timer_create (2)); | |
672e27e4 MK |
20 | the other is used as part of a mechanism that ensures all threads in |
21 | a process always have the same UIDs and GIDs, as required by POSIX. | |
22 | These signals cannot be used in applications. | |
c6d039a3 | 23 | .P |
672e27e4 MK |
24 | To prevent accidental use of these signals in applications, |
25 | which might interfere with the operation of the NPTL implementation, | |
26 | various glibc library functions and system call wrapper functions | |
27 | attempt to hide these signals from applications, | |
28 | as follows: | |
cdede5cd | 29 | .IP \[bu] 3 |
672e27e4 MK |
30 | .B SIGRTMIN |
31 | is defined with the value 34 (rather than 32). | |
cdede5cd | 32 | .IP \[bu] |
672e27e4 MK |
33 | The |
34 | .BR sigwaitinfo (2), | |
35 | .BR sigtimedwait (2), | |
36 | and | |
37 | .BR sigwait (3) | |
38 | interfaces silently ignore requests to wait for these two signals | |
39 | if they are specified in the signal set argument of these calls. | |
cdede5cd | 40 | .IP \[bu] |
672e27e4 MK |
41 | The |
42 | .BR sigprocmask (2) | |
43 | and | |
44 | .BR pthread_sigmask (3) | |
45 | interfaces silently ignore attempts to block these two signals. | |
cdede5cd | 46 | .IP \[bu] |
672e27e4 MK |
47 | The |
48 | .BR sigaction (2), | |
49 | .BR pthread_kill (3), | |
50 | and | |
51 | .BR pthread_sigqueue (3) | |
52 | interfaces fail with the error | |
53 | .B EINVAL | |
54 | (indicating an invalid signal number) if these signals are specified. | |
cdede5cd | 55 | .IP \[bu] |
672e27e4 MK |
56 | .BR sigfillset (3) |
57 | does not include these two signals when it creates a full signal set. | |
58 | .\" | |
59 | .SS NPTL and process credential changes | |
60 | At the Linux kernel level, | |
61 | credentials (user and group IDs) are a per-thread attribute. | |
62 | However, POSIX requires that all of the POSIX threads in a process | |
63 | have the same credentials. | |
64 | To accommodate this requirement, | |
65 | the NPTL implementation wraps all of the system calls that | |
66 | change process credentials with functions that, | |
67 | in addition to invoking the underlying system call, | |
68 | arrange for all other threads in the process to also change their credentials. | |
c6d039a3 | 69 | .P |
458abbe6 | 70 | The implementation of each of these system calls involves the use of |
672e27e4 MK |
71 | a real-time signal that is sent (using |
72 | .BR tgkill (2)) | |
44d88074 | 73 | to each of the other threads that must change its credentials. |
672e27e4 MK |
74 | Before sending these signals, the thread that is changing credentials |
75 | saves the new credential(s) and records the system call being employed | |
76 | in a global buffer. | |
77 | A signal handler in the receiving thread(s) fetches this information and | |
78 | then uses the same system call to change its credentials. | |
c6d039a3 | 79 | .P |
672e27e4 MK |
80 | Wrapper functions employing this technique are provided for |
81 | .BR setgid (2), | |
82 | .BR setuid (2), | |
83 | .BR setegid (2), | |
84 | .BR seteuid (2), | |
85 | .BR setregid (2), | |
86 | .BR setreuid (2), | |
87 | .BR setresgid (2), | |
88 | .BR setresuid (2), | |
89 | and | |
90 | .BR setgroups (2). | |
9470de3e MK |
91 | .\" FIXME . |
92 | .\" Maybe say something about vfork() not being serialized wrt set*id() APIs? | |
93 | .\" https://sourceware.org/bugzilla/show_bug.cgi?id=14749 | |
3113c7f3 | 94 | .SH STANDARDS |
672e27e4 MK |
95 | For details of the conformance of NPTL to the POSIX standard, see |
96 | .BR pthreads (7). | |
e50eaaf1 MK |
97 | .SH NOTES |
98 | POSIX says | |
99 | .\" See POSIX.1-2008 specification of pthread_mutexattr_init() | |
100 | that any thread in any process with access to the memory | |
101 | containing a process-shared | |
102 | .RB ( PTHREAD_PROCESS_SHARED ) | |
103 | mutex can operate on that mutex. | |
104 | However, on 64-bit x86 systems, the mutex definition for x86-64 | |
105 | is incompatible with the mutex definition for i386, | |
106 | .\" See sysdeps/x86/bits/pthreadtypes.h | |
107 | meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems. | |
672e27e4 MK |
108 | .SH SEE ALSO |
109 | .BR credentials (7), | |
110 | .BR pthreads (7), | |
111 | .BR signal (7), | |
112 | .BR standards (7) |