Debian Codegraph @

upstream/debian-trixie/man2/PR_SET_PTRACER.2const

raw
1 .\" Copyright 2013, Kees Cook <[email protected]>
2 .\" Copyright 2013, 2015, Michael Kerrisk <[email protected]>
3 .\" Copyright 2024, Alejandro Colomar <[email protected]>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH PR_SET_PTRACER 2const 2024-06-02 "Linux man-pages 6.9.1"
8 .SH NAME
9 PR_SET_PTRACER
10 \-
11 allow processes to ptrace(2) the calling process
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
17 .BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
18 .B #include <sys/prctl.h>
19 .P
20 .BI "int prctl(PR_SET_PTRACER, long " pid );
21 .fi
22 .SH DESCRIPTION
23 This is meaningful only when the Yama LSM is enabled and in mode 1
24 ("restricted ptrace", visible via
25 .IR /proc/\:sys/\:kernel/\:yama/\:ptrace_scope ).
26 .P
27 When a "ptracer process ID" is passed in
28 .IR pid ,
29 the caller is declaring that the ptracer process can
30 .BR ptrace (2)
31 the calling process as if it were a direct process ancestor.
32 .P
33 Each
34 .B PR_SET_PTRACER
35 operation replaces the previous "ptracer process ID".
36 .P
37 Employing
38 .B PR_SET_PTRACER
39 with
40 .I pid
41 set to 0 clears the caller's "ptracer process ID".
42 If
43 .I pid
44 is
45 .BR PR_SET_PTRACER_ANY ,
46 the ptrace restrictions introduced by Yama are
47 effectively disabled for the calling process.
48 .SH RETURN VALUE
49 On success,
50 0 is returned.
51 On error, \-1 is returned, and
52 .I errno
53 is set to indicate the error.
54 .SH ERRORS
55 .TP
56 .B EINVAL
57 .I pid
58 is not 0,
59 .BR PR_SET_PTRACER_ANY ,
60 nor the PID of an existing process.
61 .SH STANDARDS
62 Linux.
63 .SH HISTORY
64 Linux 3.4.
65 .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb
66 .\" commit bf06189e4d14641c0148bea16e9dd24943862215
67 .SH SEE ALSO
68 .BR prctl (2),
69 .P
70 For further information, see the kernel source file
71 .I Documentation/\:admin\-guide/\:LSM/\:Yama.rst
72 .\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22
73 (or
74 .I Documentation/\:security/\:Yama.txt
75 before Linux 4.13).