]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/nptl.7
user_namespaces.7: Minor rewordings of recently added text
[thirdparty/man-pages.git] / man7 / nptl.7
CommitLineData
672e27e4
MK
1.\" Copyright (c) 2015 by Michael Kerrisk <mtk.manpages@gmail.com>
2.\"
3.\" %%%LICENSE_START(VERBATIM)
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\" %%%LICENSE_END
24.\"
25.\"
460495ca 26.TH NPTL 7 2015-08-08 "Linux" "Linux Programmer's Manual"
672e27e4
MK
27.SH NAME
28nptl \- Native POSIX Threads Library
29.SH DESCRIPTION
30NPTL (Native POSIX Threads Library)
31is the GNU C library POSIX threads implementation that is used on modern
32Linux systems.
33.\"
34.SS NPTL and signals
35NPTL makes internal use of the first two real-time signals
36(signal numbers 32 and 33).
c99652b7
MK
37One of these signals is used to support thread cancellation and POSIX timers
38(see
39.BR timer_create (2));
672e27e4
MK
40the other is used as part of a mechanism that ensures all threads in
41a process always have the same UIDs and GIDs, as required by POSIX.
42These signals cannot be used in applications.
a721e8b2 43.PP
672e27e4
MK
44To prevent accidental use of these signals in applications,
45which might interfere with the operation of the NPTL implementation,
46various glibc library functions and system call wrapper functions
47attempt to hide these signals from applications,
48as follows:
49.IP * 3
50.B SIGRTMIN
51is defined with the value 34 (rather than 32).
52.IP *
53The
54.BR sigwaitinfo (2),
55.BR sigtimedwait (2),
56and
57.BR sigwait (3)
58interfaces silently ignore requests to wait for these two signals
59if they are specified in the signal set argument of these calls.
60.IP *
61The
62.BR sigprocmask (2)
63and
64.BR pthread_sigmask (3)
65interfaces silently ignore attempts to block these two signals.
66.IP *
67The
68.BR sigaction (2),
69.BR pthread_kill (3),
70and
71.BR pthread_sigqueue (3)
72interfaces fail with the error
73.B EINVAL
74(indicating an invalid signal number) if these signals are specified.
75.IP *
76.BR sigfillset (3)
77does not include these two signals when it creates a full signal set.
78.\"
79.SS NPTL and process credential changes
80At the Linux kernel level,
81credentials (user and group IDs) are a per-thread attribute.
82However, POSIX requires that all of the POSIX threads in a process
83have the same credentials.
84To accommodate this requirement,
85the NPTL implementation wraps all of the system calls that
86change process credentials with functions that,
87in addition to invoking the underlying system call,
88arrange for all other threads in the process to also change their credentials.
a721e8b2 89.PP
458abbe6 90The implementation of each of these system calls involves the use of
672e27e4
MK
91a real-time signal that is sent (using
92.BR tgkill (2))
44d88074 93to each of the other threads that must change its credentials.
672e27e4
MK
94Before sending these signals, the thread that is changing credentials
95saves the new credential(s) and records the system call being employed
96in a global buffer.
97A signal handler in the receiving thread(s) fetches this information and
98then uses the same system call to change its credentials.
a721e8b2 99.PP
672e27e4
MK
100Wrapper functions employing this technique are provided for
101.BR setgid (2),
102.BR setuid (2),
103.BR setegid (2),
104.BR seteuid (2),
105.BR setregid (2),
106.BR setreuid (2),
107.BR setresgid (2),
108.BR setresuid (2),
109and
110.BR setgroups (2).
9470de3e
MK
111.\" FIXME .
112.\" Maybe say something about vfork() not being serialized wrt set*id() APIs?
113.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14749
672e27e4
MK
114.SH CONFORMING TO
115For details of the conformance of NPTL to the POSIX standard, see
116.BR pthreads (7).
e50eaaf1
MK
117.SH NOTES
118POSIX says
119.\" See POSIX.1-2008 specification of pthread_mutexattr_init()
120that any thread in any process with access to the memory
121containing a process-shared
122.RB ( PTHREAD_PROCESS_SHARED )
123mutex can operate on that mutex.
124However, on 64-bit x86 systems, the mutex definition for x86-64
125is incompatible with the mutex definition for i386,
126.\" See sysdeps/x86/bits/pthreadtypes.h
127meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems.
672e27e4
MK
128.SH SEE ALSO
129.BR credentials (7),
130.BR pthreads (7),
131.BR signal (7),
132.BR standards (7)