1.\" Copyright (c) 2013 Hudson River Trading LLC 2.\" Written by: John H. Baldwin <[email protected]> 3.\" All rights reserved. 4.\" 5.\" Copyright (c) 2014 The FreeBSD Foundation 6.\" Portions of this documentation were written by Konstantin Belousov 7.\" under sponsorship from the FreeBSD Foundation. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" $FreeBSD$ 31.\" 32.Dd September 2, 2021 33.Dt PROCCTL 2 34.Os 35.Sh NAME 36.Nm procctl 37.Nd control processes 38.Sh LIBRARY 39.Lb libc 40.Sh SYNOPSIS 41.In sys/procctl.h 42.Ft int 43.Fn procctl "idtype_t idtype" "id_t id" "int cmd" "void *data" 44.Sh DESCRIPTION 45The 46.Fn procctl 47system call provides for control over processes. 48The 49.Fa idtype 50and 51.Fa id 52arguments specify the set of processes to control. 53If multiple processes match the identifier, 54.Nm 55will make a 56.Dq best effort 57to control as many of the selected processes as possible. 58An error is only returned if no selected processes successfully complete 59the request. 60The following identifier types are supported: 61.Bl -tag -width P_PGID 62.It Dv P_PID 63Control the process with the process ID 64.Fa id . 65.Fa id 66zero is a shortcut for the calling process ID. 67.It Dv P_PGID 68Control processes belonging to the process group with the ID 69.Fa id . 70.El 71.Pp 72The control request to perform is specified by the 73.Fa cmd 74argument. 75.Pp 76All status changing requests 77.Dv *_CTL 78require the caller to have the right to debug the target. 79All status query requests 80.DV *_STATUS 81require the caller to have the right to observe the target. 82.Pp 83The following commands are supported: 84.Bl -tag -width PROC_TRAPCAP_STATUS 85.It Dv PROC_ASLR_CTL 86Controls the Address Space Layout Randomization (ASLR) in the program 87images created 88by 89.Xr execve 2 90in the specified process or its descendants that did not changed 91the control nor modified it by other means. 92The 93.Fa data 94parameter must point to the integer variable holding one of the following 95values: 96.Bl -tag -width PROC_ASLR_FORCE_DISABLE 97.It Dv PROC_ASLR_FORCE_ENABLE 98Request that ASLR is enabled after execution, even if it is disabled 99system-wide. 100The image flag and set-uid might prevent ASLR enablement still. 101.It Dv PROC_ASLR_FORCE_DISABLE 102Request that ASLR is disabled after execution. 103Same notes as for 104.Dv PROC_ASLR_FORCE_ENABLE 105apply. 106.It Dv PROC_ASLR_NOFORCE 107Use the system-wide configured policy for ASLR. 108.El 109.It Dv PROC_ASLR_STATUS 110Returns the current status of ASLR enablement for the target process. 111The 112.Fa data 113parameter must point to the integer variable, where one of the 114following values is written: 115.Bl -tag -width PROC_ASLR_FORCE_DISABLE 116.It Dv PROC_ASLR_FORCE_ENABLE 117.It Dv PROC_ASLR_FORCE_DISABLE 118.It Dv PROC_ASLR_NOFORCE 119.El 120.Pp 121If the currently executed image in the process itself has ASLR enabled, 122the 123.Dv PROC_ASLR_ACTIVE 124flag is or-ed with the value listed above. 125.It Dv PROC_PROTMAX_CTL 126Controls implicit application of PROT_MAX protection equal to the 127.Fa prot 128argument of the 129.Xr mmap 2 130syscall, in the target process. 131The 132.Fa data 133parameter must point to the integer variable holding one of the following 134values: 135.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE 136.It Dv PROC_PROTMAX_FORCE_ENABLE 137Enables implicit PROT_MAX application, 138even if it is disabled system-wide by the sysctl 139.Va vm.imply_prot_max . 140The image flag might still prevent the enablement. 141.It Dv PROC_PROTMAX_FORCE_DISABLE 142Request that implicit application of PROT_MAX be disabled. 143Same notes as for 144.Dv PROC_PROTMAX_FORCE_ENABLE 145apply. 146.It Dv PROC_PROTMAX_NOFORCE 147Use the system-wide configured policy for PROT_MAX. 148.El 149.It Dv PROC_PROTMAX_STATUS 150Returns the current status of implicit PROT_MAX enablement for the 151target process. 152The 153.Fa data 154parameter must point to the integer variable, where one of the 155following values is written: 156.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE 157.It Dv PROC_PROTMAX_FORCE_ENABLE 158.It Dv PROC_PROTMAX_FORCE_DISABLE 159.It Dv PROC_PROTMAX_NOFORCE 160.El 161.Pp 162If the currently executed image in the process itself has implicit PROT_MAX 163application enabled, the 164.Dv PROC_PROTMAX_ACTIVE 165flag is or-ed with the value listed above. 166.It Dv PROC_SPROTECT 167Set process protection state. 168This is used to mark a process as protected from being killed if the system 169exhausts the available memory and swap. 170The 171.Fa data 172parameter must point to an integer containing an operation and zero or more 173optional flags. 174The following operations are supported: 175.Bl -tag -width PPROT_CLEAR 176.It Dv PPROT_SET 177Mark the selected processes as protected. 178.It Dv PPROT_CLEAR 179Clear the protected state of selected processes. 180.El 181.Pp 182The following optional flags are supported: 183.Bl -tag -width PPROT_DESCEND 184.It Dv PPROT_DESCEND 185Apply the requested operation to all child processes of each selected process 186in addition to each selected process. 187.It Dv PPROT_INHERIT 188When used with 189.Dv PPROT_SET , 190mark all future child processes of each selected process as protected. 191Future child processes will also mark all of their future child processes. 192.El 193.It Dv PROC_REAP_ACQUIRE 194Acquires the reaper status for the current process. 195Reaper status means that children orphaned by the reaper's descendants 196that were forked after the acquisition of reaper status are reparented to the 197reaper process. 198After system initialization, 199.Xr init 8 200is the default reaper. 201.It Dv PROC_REAP_RELEASE 202Release the reaper state for the current process. 203The reaper of the current process becomes the new reaper of the 204current process's descendants. 205.It Dv PROC_REAP_STATUS 206Provides information about the reaper of the specified process, 207or the process itself when it is a reaper. 208The 209.Fa data 210argument must point to a 211.Vt procctl_reaper_status 212structure which is filled in by the syscall on successful return. 213.Bd -literal 214struct procctl_reaper_status { 215 u_int rs_flags; 216 u_int rs_children; 217 u_int rs_descendants; 218 pid_t rs_reaper; 219 pid_t rs_pid; 220}; 221.Ed 222The 223.Fa rs_flags 224may have the following flags returned: 225.Bl -tag -width REAPER_STATUS_REALINIT 226.It Dv REAPER_STATUS_OWNED 227The specified process has acquired reaper status and has not 228released it. 229When the flag is returned, the specified process 230.Fa id , 231pid, identifies the reaper, otherwise the 232.Fa rs_reaper 233field of the structure is set to the pid of the reaper 234for the specified process id. 235.It Dv REAPER_STATUS_REALINIT 236The specified process is the root of the reaper tree, i.e., 237.Xr init 8 . 238.El 239.Pp 240The 241.Fa rs_children 242field returns the number of children of the reaper among the descendants. 243It is possible to have a child whose reaper is not the specified process, 244since the reaper for any existing children is not reset on the 245.Dv PROC_REAP_ACQUIRE 246operation. 247The 248.Fa rs_descendants 249field returns the total number of descendants of the reaper(s), 250not counting descendants of the reaper in the subtree. 251The 252.Fa rs_reaper 253field returns the reaper pid. 254The 255.Fa rs_pid 256returns the pid of one reaper child if there are any descendants. 257.It Dv PROC_REAP_GETPIDS 258Queries the list of descendants of the reaper of the specified process. 259The request takes a pointer to a 260.Vt procctl_reaper_pids 261structure in the 262.Fa data 263parameter. 264.Bd -literal 265struct procctl_reaper_pids { 266 u_int rp_count; 267 struct procctl_reaper_pidinfo *rp_pids; 268}; 269.Ed 270When called, the 271.Fa rp_pids 272field must point to an array of 273.Vt procctl_reaper_pidinfo 274structures, to be filled in on return, 275and the 276.Fa rp_count 277field must specify the size of the array, 278into which no more than 279.Fa rp_count 280elements will be filled in by the kernel. 281.Pp 282The 283.Vt "struct procctl_reaper_pidinfo" 284structure provides some information about one of the reaper's descendants. 285Note that for a descendant that is not a child, it may be incorrectly 286identified because of a race in which the original child process exited 287and the exited process's pid was reused for an unrelated process. 288.Bd -literal 289struct procctl_reaper_pidinfo { 290 pid_t pi_pid; 291 pid_t pi_subtree; 292 u_int pi_flags; 293}; 294.Ed 295The 296.Fa pi_pid 297field is the process id of the descendant. 298The 299.Fa pi_subtree 300field provides the pid of the child of the reaper, which is the (grand-)parent 301of the process. 302The 303.Fa pi_flags 304field returns the following flags, further describing the descendant: 305.Bl -tag -width REAPER_PIDINFO_REAPER 306.It Dv REAPER_PIDINFO_VALID 307Set to indicate that the 308.Vt procctl_reaper_pidinfo 309structure was filled in by the kernel. 310Zero-filling the 311.Fa rp_pids 312array and testing the 313.Dv REAPER_PIDINFO_VALID 314flag allows the caller to detect the end 315of the returned array. 316.It Dv REAPER_PIDINFO_CHILD 317The 318.Fa pi_pid 319field identifies the direct child of the reaper. 320.It Dv REAPER_PIDINFO_REAPER 321The reported process is itself a reaper. 322The descendants of the subordinate reaper are not reported. 323.El 324.It Dv PROC_REAP_KILL 325Request to deliver a signal to some subset of the descendants of the reaper. 326The 327.Fa data 328parameter must point to a 329.Vt procctl_reaper_kill 330structure, which is used both for parameters and status return. 331.Bd -literal 332struct procctl_reaper_kill { 333 int rk_sig; 334 u_int rk_flags; 335 pid_t rk_subtree; 336 u_int rk_killed; 337 pid_t rk_fpid; 338}; 339.Ed 340The 341.Fa rk_sig 342field specifies the signal to be delivered. 343Zero is not a valid signal number, unlike for 344.Xr kill 2 . 345The 346.Fa rk_flags 347field further directs the operation. 348It is or-ed from the following flags: 349.Bl -tag -width REAPER_KILL_CHILDREN 350.It Dv REAPER_KILL_CHILDREN 351Deliver the specified signal only to direct children of the reaper. 352.It Dv REAPER_KILL_SUBTREE 353Deliver the specified signal only to descendants that were forked by 354the direct child with pid specified in the 355.Fa rk_subtree 356field. 357.El 358If neither the 359.Dv REAPER_KILL_CHILDREN 360nor the 361.Dv REAPER_KILL_SUBTREE 362flags are specified, all current descendants of the reaper are signalled. 363.Pp 364If a signal was delivered to any process, the return value from the request 365is zero. 366In this case, the 367.Fa rk_killed 368field identifies the number of processes signalled. 369The 370.Fa rk_fpid 371field is set to the pid of the first process for which signal 372delivery failed, e.g., due to permission problems. 373If no such process exists, the 374.Fa rk_fpid 375field is set to -1. 376.It Dv PROC_TRACE_CTL 377Enable or disable tracing of the specified process(es), according to the 378value of the integer argument. 379Tracing includes attachment to the process using the 380.Xr ptrace 2 381and 382.Xr ktrace 2 , 383debugging sysctls, 384.Xr hwpmc 4 , 385.Xr dtrace 1 , 386and core dumping. 387Possible values for the 388.Fa data 389argument are: 390.Bl -tag -width PROC_TRACE_CTL_DISABLE_EXEC 391.It Dv PROC_TRACE_CTL_ENABLE 392Enable tracing, after it was disabled by 393.Dv PROC_TRACE_CTL_DISABLE . 394Only allowed for self. 395.It Dv PROC_TRACE_CTL_DISABLE 396Disable tracing for the specified process. 397Tracing is re-enabled when the process changes the executing 398program with the 399.Xr execve 2 400syscall. 401A child inherits the trace settings from the parent on 402.Xr fork 2 . 403.It Dv PROC_TRACE_CTL_DISABLE_EXEC 404Same as 405.Dv PROC_TRACE_CTL_DISABLE , 406but the setting persists for the process even after 407.Xr execve 2 . 408.El 409.It Dv PROC_TRACE_STATUS 410Returns the current tracing status for the specified process in 411the integer variable pointed to by 412.Fa data . 413If tracing is disabled, 414.Fa data 415is set to -1. 416If tracing is enabled, but no debugger is attached by the 417.Xr ptrace 2 418syscall, 419.Fa data 420is set to 0. 421If a debugger is attached, 422.Fa data 423is set to the pid of the debugger process. 424.It Dv PROC_TRAPCAP_CTL 425Controls the capability mode sandbox actions for the specified 426sandboxed processes, 427on a return from any syscall which gives either a 428.Er ENOTCAPABLE 429or 430.Er ECAPMODE 431error. 432If the control is enabled, such errors from the syscalls cause 433delivery of the synchronous 434.Dv SIGTRAP 435signal to the thread immediately before returning from the syscalls. 436.Pp 437Possible values for the 438.Fa data 439argument are: 440.Bl -tag -width PROC_TRAPCAP_CTL_DISABLE 441.It Dv PROC_TRAPCAP_CTL_ENABLE 442Enable the 443.Dv SIGTRAP 444signal delivery on capability mode access violations. 445The enabled mode is inherited by the children of the process, 446and is kept after 447.Xr fexecve 2 448calls. 449.It Dv PROC_TRAPCAP_CTL_DISABLE 450Disable the signal delivery on capability mode access violations. 451Note that the global sysctl 452.Dv kern.trap_enotcap 453might still cause the signal to be delivered. 454See 455.Xr capsicum 4 . 456.El 457.Pp 458On signal delivery, the 459.Va si_errno 460member of the 461.Fa siginfo 462signal handler parameter is set to the syscall error value, 463and the 464.Va si_code 465member is set to 466.Dv TRAP_CAP . 467The system call number is stored in the 468.Va si_syscall 469field of the 470.Fa siginfo 471signal handler parameter. 472The other system call parameters can be read from the 473.Fa ucontext_t 474but the system call number is typically stored in the register 475that also contains the return value and so is unavailable in the 476signal handler. 477.Pp 478See 479.Xr capsicum 4 480for more information about the capability mode. 481.It Dv PROC_TRAPCAP_STATUS 482Return the current status of signalling capability mode access 483violations for the specified process. 484The integer value pointed to by the 485.Fa data 486argument is set to the 487.Dv PROC_TRAPCAP_CTL_ENABLE 488value if the process control enables signal delivery, and to 489.Dv PROC_TRAPCAP_CTL_DISABLE 490otherwise. 491.Pp 492See the note about sysctl 493.Dv kern.trap_enotcap 494above, which gives independent global control of signal delivery. 495.It Dv PROC_PDEATHSIG_CTL 496Request the delivery of a signal when the parent of the calling 497process exits. 498.Fa idtype 499must be 500.Dv P_PID 501and 502.Fa id 503must be the either caller's pid or zero, with no difference in effect. 504The value is cleared for child processes 505and when executing set-user-ID or set-group-ID binaries. 506.Fa data 507must point to a value of type 508.Vt int 509indicating the signal 510that should be delivered to the caller. 511Use zero to cancel a previously requested signal delivery. 512.It Dv PROC_PDEATHSIG_STATUS 513Query the current signal number that will be delivered when the parent 514of the calling process exits. 515.Fa idtype 516must be 517.Dv P_PID 518and 519.Fa id 520must be the either caller's pid or zero, with no difference in effect. 521.Fa data 522must point to a memory location that can hold a value of type 523.Vt int . 524If signal delivery has not been requested, it will contain zero 525on return. 526.It Dv PROC_STACKGAP_CTL 527Controls the stack gaps in the specified process. 528A stack gap is the part of the growth area for a 529.Dv MAP_STACK 530mapped region that is reserved and never filled by memory. 531Instead, the process is guaranteed to receive a 532.Dv SIGSEGV 533signal on accessing pages in the gap. 534Gaps protect against stack overflow corrupting memory adjacent 535to the stack. 536.Pp 537The 538.Fa data 539argument must point to an integer variable containing flags. 540The following flags are allowed: 541.Bl -tag -width PROC_STACKGAP_DISABLE_EXEC 542.It Dv PROC_STACKGAP_ENABLE 543This flag is only accepted for consistency with 544.Dv PROC_STACKGAP_STATUS . 545If stack gaps are enabled, the flag is ignored. 546If disabled, the flag causes an 547.Ev EINVAL 548error to be returned. 549After gaps are disabled in a process, they can only be re-enabled when an 550.Xr execve 2 551is performed. 552.It Dv PROC_STACKGAP_DISABLE 553Disable stack gaps for the process. 554For existing stacks, the gap is no longer a reserved part of the growth 555area and can be filled by memory on access. 556.It Dv PROC_STACKGAP_ENABLE_EXEC 557Enable stack gaps for programs started after an 558.Xr execve 2 559by the specified process. 560.It Dv PROC_STACKGAP_DISABLE_EXEC 561Inherit disabled stack gaps state after 562.Xr execve 2 . 563In other words, if the currently executing program has stack gaps disabled, 564they are kept disabled on exec. 565If gaps were enabled, they are kept enabled after exec. 566.El 567.Pp 568The stack gap state is inherited from the parent on 569.Xr fork 2 . 570.It Dv PROC_STACKGAP_STATUS 571Returns the current stack gap state for the specified process. 572.Fa data 573must point to an integer variable, which is used to return a bitmask 574consisting of the following flags: 575.Bl -tag -width PROC_STACKGAP_DISABLE_EXEC 576.It Dv PROC_STACKGAP_ENABLE 577Stack gaps are enabled. 578.It Dv PROC_STACKGAP_DISABLE 579Stack gaps are disabled. 580.It Dv PROC_STACKGAP_ENABLE_EXEC 581Stack gaps are enabled in the process after 582.Xr execve 2 . 583.It Dv PROC_STACKGAP_DISABLE_EXEC 584Stack gaps are disabled in the process after 585.Xr execve 2 . 586.El 587.It Dv PROC_NO_NEW_PRIVS_CTL 588Allows one to ignore the SUID and SGID bits on the program 589images activated by 590.Xr execve 2 591in the specified process and its future descendants. 592The 593.Fa data 594parameter must point to the integer variable holding the following 595value: 596.Bl -tag -width PROC_NO_NEW_PRIVS_ENABLE 597.It Dv PROC_NO_NEW_PRIVS_ENABLE 598Request SUID and SGID bits to be ignored. 599.El 600.Pp 601It is not possible to disable it once it has been enabled. 602.It Dv PROC_NO_NEW_PRIVS_STATUS 603Returns the current status of SUID/SGID enablement for the target process. 604The 605.Fa data 606parameter must point to the integer variable, where one of the 607following values is written: 608.Bl -tag -width PROC_NO_NEW_PRIVS_DISABLE 609.It Dv PROC_NO_NEW_PRIVS_ENABLE 610.It Dv PROC_NO_NEW_PRIVS_DISABLE 611.El 612.It Dv PROC_WXMAP_CTL 613Controls the 'write exclusive against execution' permissions for the 614mappings in the process address space. 615It overrides the global settings established by the 616.Dv kern.elf{32/64}.allow_wx 617sysctl, 618and the corresponding bit in the ELF control note, see 619.Xr elfctl 1 . 620.Pp 621The 622.Fa data 623parameter must point to the integer variable holding one of the 624following values: 625.Bl -tag -width PROC_WX_MAPPINGS_DISALLOW_EXEC 626.It Dv PROC_WX_MAPPINGS_PERMIT 627Enable creation of mappings that have both write and execute 628protection attributes, in the specified process' address space. 629.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC 630In the new address space created by 631.Xr execve 2 , 632disallow creation of mappings that have both write and execute 633permissions. 634.El 635.Pp 636Once creation of writeable and executable mappings is allowed, 637it is impossible (and pointless) to disallow it. 638The only way to ensure the absence of such mappings after they 639were enabled in a given process, is to set the 640.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC 641flag and 642.Xr execve 2 643an image. 644.It Dv PROC_WXMAP_STATUS 645Returns the current status of the 'write exclusive against execution' 646enforcement for the specified process. 647The 648.Dv data 649parameter must point to the integer variable, where one of the 650following values is written: 651.Bl -tag -width PROC_WX_MAPPINGS_DISALLOW_EXEC 652.It Dv PROC_WX_MAPPINGS_PERMIT 653Creation of simultaneously writable and executable mapping is permitted, 654otherwise the process cannot create such mappings. 655.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC 656After 657.Xr execve 2 , 658the new address space should disallow creation of simultaneously 659writable and executable mappings. 660.El 661.Pp 662Additionally, if the address space of the process disallows 663creation of simultaneously writable and executable mappings and 664it is guaranteed that no such mapping was created since address space 665creation, the 666.Dv PROC_WXORX_ENFORCE 667flag is set in the returned value. 668.El 669.Sh x86 MACHINE-SPECIFIC REQUESTS 670.Bl -tag -width PROC_KPTI_STATUS 671.It Dv PROC_KPTI_CTL 672AMD64 only. 673Controls the Kernel Page Table Isolation (KPTI) option for the children 674of the specified process. 675For the command to work, the 676.Va vm.pmap.kpti 677tunable must be enabled on boot. 678It is not possible to change the KPTI setting for a running process, 679except at the 680.Xr execve 2 , 681where the address space is reinitialized. 682.Pp 683The 684.Fa data 685parameter must point to an integer variable containing one of the 686following commands: 687.Bl -tag -width PROC_KPTI_CTL_DISABLE_ON_EXEC 688.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC 689Enable KPTI after 690.Xr execve 2 . 691.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC 692Disable KPTI after 693.Xr execve 2 . 694Only root or a process having the 695.Va PRIV_IO 696privilege might use this option. 697.El 698.It Dv PROC_KPTI_STATUS 699Returns the current KPTI status for the specified process. 700.Fa data 701must point to the integer variable, which returns the 702following statuses: 703.Bl -tag -width PROC_KPTI_CTL_DISABLE_ON_EXEC 704.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC 705.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC 706.El 707.Pp 708The status is or-ed with the 709.Va PROC_KPTI_STATUS_ACTIVE 710in case KPTI is active for the current address space of the process. 711.Sh NOTES 712Disabling tracing on a process should not be considered a security 713feature, as it is bypassable both by the kernel and privileged processes, 714and via other system mechanisms. 715As such, it should not be utilized to reliably protect cryptographic 716keying material or other confidential data. 717.Pp 718Note that processes can trivially bypass the 'no simultaneously 719writable and executable mappings' policy by first marking some mapping 720as writeable and write code to it, then removing write and adding 721execute permission. 722This may be legitimately required by some programs, such as JIT compilers. 723.Sh RETURN VALUES 724If an error occurs, a value of -1 is returned and 725.Va errno 726is set to indicate the error. 727.Sh ERRORS 728The 729.Fn procctl 730system call 731will fail if: 732.Bl -tag -width Er 733.It Bq Er EFAULT 734The 735.Fa data 736parameter points outside the process's allocated address space. 737.It Bq Er EINVAL 738The 739.Fa cmd 740argument specifies an unsupported command. 741.Pp 742The 743.Fa idtype 744argument specifies an unsupported identifier type. 745.It Bq Er EPERM 746The calling process does not have permission to perform the requested 747operation on any of the selected processes. 748.It Bq Er ESRCH 749No processes matched the requested 750.Fa idtype 751and 752.Fa id . 753.It Bq Er EINVAL 754An invalid operation or flag was passed in 755.Fa data 756for a 757.Dv PROC_SPROTECT 758command. 759.It Bq Er EPERM 760The 761.Fa idtype 762argument is not equal to 763.Dv P_PID , 764or 765.Fa id 766is not equal to the pid of the calling process, for 767.Dv PROC_REAP_ACQUIRE 768or 769.Dv PROC_REAP_RELEASE 770requests. 771.It Bq Er EINVAL 772Invalid or undefined flags were passed to a 773.Dv PROC_REAP_KILL 774request. 775.It Bq Er EINVAL 776An invalid or zero signal number was requested for a 777.Dv PROC_REAP_KILL 778request. 779.It Bq Er EINVAL 780The 781.Dv PROC_REAP_RELEASE 782request was issued by the 783.Xr init 8 784process. 785.It Bq Er EBUSY 786The 787.Dv PROC_REAP_ACQUIRE 788request was issued by a process that had already acquired reaper status 789and has not yet released it. 790.It Bq Er EBUSY 791The 792.Dv PROC_TRACE_CTL 793request was issued for a process already being traced. 794.It Bq Er EPERM 795The 796.Dv PROC_TRACE_CTL 797request to re-enable tracing of the process 798.Po Dv PROC_TRACE_CTL_ENABLE Pc , 799or to disable persistence of 800.Dv PROC_TRACE_CTL_DISABLE 801on 802.Xr execve 2 803was issued for a non-current process. 804.It Bq Er EINVAL 805The value of the integer 806.Fa data 807parameter for the 808.Dv PROC_TRACE_CTL 809or 810.Dv PROC_TRAPCAP_CTL 811request is invalid. 812.It Bq Er EINVAL 813The 814.Dv PROC_PDEATHSIG_CTL 815or 816.Dv PROC_PDEATHSIG_STATUS 817request referenced an unsupported 818.Fa id , 819.Fa idtype 820or invalid signal number. 821.El 822.Sh SEE ALSO 823.Xr dtrace 1 , 824.Xr proccontrol 1 , 825.Xr protect 1 , 826.Xr cap_enter 2 , 827.Xr kill 2 , 828.Xr ktrace 2 , 829.Xr mmap 2 , 830.Xr mprotect 2 , 831.Xr ptrace 2 , 832.Xr wait 2 , 833.Xr capsicum 4 , 834.Xr hwpmc 4 , 835.Xr init 8 836.Sh HISTORY 837The 838.Fn procctl 839function appeared in 840.Fx 10.0 . 841.Pp 842The reaper facility is based on a similar feature of Linux and 843DragonflyBSD, and first appeared in 844.Fx 10.2 . 845.Pp 846The 847.Dv PROC_PDEATHSIG_CTL 848facility is based on the prctl(PR_SET_PDEATHSIG, ...) feature of Linux, 849and first appeared in 850.Fx 11.2 . 851.Pp 852The ASLR support was added to system for the checklists compliance in 853.Fx 13.0 . 854