2015-04-23 10:22:20 -04:00
|
|
|
.\" Copyright (c) 2013 Hudson River Trading LLC
|
2013-09-19 14:53:42 -04:00
|
|
|
.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
|
|
|
|
|
.\" All rights reserved.
|
|
|
|
|
.\"
|
2014-12-15 07:01:42 -05:00
|
|
|
.\" Copyright (c) 2014 The FreeBSD Foundation
|
|
|
|
|
.\" Portions of this documentation were written by Konstantin Belousov
|
|
|
|
|
.\" under sponsorship from the FreeBSD Foundation.
|
|
|
|
|
.\"
|
2013-09-19 14:53:42 -04:00
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
|
.\" are met:
|
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
|
.\"
|
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
|
.\"
|
2024-12-04 09:11:19 -05:00
|
|
|
.Dd December 4, 2024
|
2013-09-19 14:53:42 -04:00
|
|
|
.Dt PROCCTL 2
|
|
|
|
|
.Os
|
|
|
|
|
.Sh NAME
|
|
|
|
|
.Nm procctl
|
|
|
|
|
.Nd control processes
|
|
|
|
|
.Sh LIBRARY
|
|
|
|
|
.Lb libc
|
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
|
.In sys/procctl.h
|
|
|
|
|
.Ft int
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fn procctl "idtype_t idtype" "id_t id" "int cmd" "void *data"
|
2013-09-19 14:53:42 -04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
|
The
|
|
|
|
|
.Fn procctl
|
|
|
|
|
system call provides for control over processes.
|
|
|
|
|
The
|
|
|
|
|
.Fa idtype
|
|
|
|
|
and
|
|
|
|
|
.Fa id
|
|
|
|
|
arguments specify the set of processes to control.
|
|
|
|
|
If multiple processes match the identifier,
|
|
|
|
|
.Nm
|
|
|
|
|
will make a
|
|
|
|
|
.Dq best effort
|
2014-07-08 21:33:35 -04:00
|
|
|
to control as many of the selected processes as possible.
|
2013-09-19 14:53:42 -04:00
|
|
|
An error is only returned if no selected processes successfully complete
|
|
|
|
|
the request.
|
|
|
|
|
The following identifier types are supported:
|
2019-02-26 12:35:06 -05:00
|
|
|
.Bl -tag -width P_PGID
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Dv P_PID
|
|
|
|
|
Control the process with the process ID
|
|
|
|
|
.Fa id .
|
2021-10-15 15:01:42 -04:00
|
|
|
.Fa id
|
|
|
|
|
zero is a shortcut for the calling process ID.
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Dv P_PGID
|
|
|
|
|
Control processes belonging to the process group with the ID
|
|
|
|
|
.Fa id .
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
The control request to perform is specified by the
|
|
|
|
|
.Fa cmd
|
|
|
|
|
argument.
|
2021-10-15 16:09:39 -04:00
|
|
|
.Pp
|
|
|
|
|
All status changing requests
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pq Dv *_CTL
|
2021-10-15 16:09:39 -04:00
|
|
|
require the caller to have the right to debug the target.
|
|
|
|
|
All status query requests
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pq Dv *_STATUS
|
2021-10-15 16:09:39 -04:00
|
|
|
require the caller to have the right to observe the target.
|
|
|
|
|
.Pp
|
2013-09-19 14:53:42 -04:00
|
|
|
The following commands are supported:
|
2019-02-26 12:35:06 -05:00
|
|
|
.Bl -tag -width PROC_TRAPCAP_STATUS
|
2019-02-26 12:41:41 -05:00
|
|
|
.It Dv PROC_ASLR_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
Controls Address Space Layout Randomization (ASLR) in program
|
2019-02-26 12:41:41 -05:00
|
|
|
images created
|
|
|
|
|
by
|
|
|
|
|
.Xr execve 2
|
2023-10-26 13:38:14 -04:00
|
|
|
in the specified process or its descendants that do not either change
|
|
|
|
|
the control or modify it by other means.
|
2019-02-26 12:41:41 -05:00
|
|
|
The
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable holding one of the following
|
2019-02-26 12:41:41 -05:00
|
|
|
values:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-02-26 12:41:41 -05:00
|
|
|
.It Dv PROC_ASLR_FORCE_ENABLE
|
|
|
|
|
Request that ASLR is enabled after execution, even if it is disabled
|
|
|
|
|
system-wide.
|
|
|
|
|
.It Dv PROC_ASLR_FORCE_DISABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Request that ASLR is disabled after execution, even if it is enabled
|
|
|
|
|
system-wide.
|
2019-02-26 12:41:41 -05:00
|
|
|
.It Dv PROC_ASLR_NOFORCE
|
2019-07-02 15:07:17 -04:00
|
|
|
Use the system-wide configured policy for ASLR.
|
2019-02-26 12:41:41 -05:00
|
|
|
.El
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
|
|
|
|
Note that the
|
|
|
|
|
.Xr elfctl 1
|
|
|
|
|
.Dq noaslr
|
|
|
|
|
flag takes precedence over this control.
|
|
|
|
|
Executing a binary with this flag set will never use ASLR.
|
|
|
|
|
Similarly, executing a set-user-ID or set-group-ID binary ignores this
|
|
|
|
|
control and only honors the
|
|
|
|
|
.Xr elfctl 1
|
|
|
|
|
flag and system-wide policy.
|
2019-02-26 12:41:41 -05:00
|
|
|
.It Dv PROC_ASLR_STATUS
|
|
|
|
|
Returns the current status of ASLR enablement for the target process.
|
|
|
|
|
The
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable, where one of the
|
2019-02-26 12:41:41 -05:00
|
|
|
following values is written:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-02-26 12:41:41 -05:00
|
|
|
.It Dv PROC_ASLR_FORCE_ENABLE
|
|
|
|
|
.It Dv PROC_ASLR_FORCE_DISABLE
|
|
|
|
|
.It Dv PROC_ASLR_NOFORCE
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
If the currently executed image in the process itself has ASLR enabled,
|
|
|
|
|
the
|
|
|
|
|
.Dv PROC_ASLR_ACTIVE
|
|
|
|
|
flag is or-ed with the value listed above.
|
2019-07-02 15:07:17 -04:00
|
|
|
.It Dv PROC_PROTMAX_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
Controls the maximum protection used for
|
2019-07-02 15:07:17 -04:00
|
|
|
.Xr mmap 2
|
2024-12-04 09:11:19 -05:00
|
|
|
requests in the target process that do not specify
|
|
|
|
|
an explicit maximum protection in the
|
|
|
|
|
.Fa prot
|
|
|
|
|
argument via
|
|
|
|
|
.Dv PROT_MAX .
|
|
|
|
|
The maximum protection limits the permissions a mapping can be assigned by
|
|
|
|
|
.Xr mprotect 2 .
|
|
|
|
|
If an explicit maximum protection is not provided,
|
|
|
|
|
the maximum protection for a new mapping is set to either
|
|
|
|
|
.Dv PROT_READ | PROT_WRITE | PROT_EXEC
|
|
|
|
|
.Pq RWX
|
|
|
|
|
or the protection specified in
|
|
|
|
|
.Fa prot .
|
|
|
|
|
Mappings created with
|
|
|
|
|
.Fa prot
|
|
|
|
|
set to
|
|
|
|
|
.Dv PROT_NONE
|
|
|
|
|
always use RWX maximum protection.
|
|
|
|
|
.Pp
|
2019-07-02 15:07:17 -04:00
|
|
|
The
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable holding one of the following
|
2019-07-02 15:07:17 -04:00
|
|
|
values:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-07-02 15:07:17 -04:00
|
|
|
.It Dv PROC_PROTMAX_FORCE_ENABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Use the permissions in
|
|
|
|
|
.Fa prot
|
|
|
|
|
as the implicit maximum protection,
|
|
|
|
|
even if RWX permissions are requested by the sysctl
|
2019-07-02 15:07:17 -04:00
|
|
|
.Va vm.imply_prot_max .
|
2020-05-16 00:52:29 -04:00
|
|
|
.It Dv PROC_PROTMAX_FORCE_DISABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Use RWX as the implicit maximum protection,
|
|
|
|
|
even if constrained permissions are requested by the sysctl
|
|
|
|
|
.Va vm.imply_prot_max .
|
2019-07-02 15:07:17 -04:00
|
|
|
.It Dv PROC_PROTMAX_NOFORCE
|
2024-12-04 09:11:19 -05:00
|
|
|
Use the system-wide configured policy for the implicit PROT_MAX control.
|
2019-07-02 15:07:17 -04:00
|
|
|
.El
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
|
|
|
|
Note that the
|
|
|
|
|
.Xr elfctl 1
|
|
|
|
|
.Dq noprotmax
|
|
|
|
|
flag takes precedence over this control.
|
|
|
|
|
Executing a binary with this flag set will always use RWX as the implicit
|
|
|
|
|
maximum protection.
|
2019-07-02 15:07:17 -04:00
|
|
|
.It Dv PROC_PROTMAX_STATUS
|
2024-12-04 09:11:19 -05:00
|
|
|
Returns the current status of the implicit PROT_MAX control for the
|
2019-07-02 15:07:17 -04:00
|
|
|
target process.
|
|
|
|
|
The
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable, where one of the
|
2019-07-02 15:07:17 -04:00
|
|
|
following values is written:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-07-02 15:07:17 -04:00
|
|
|
.It Dv PROC_PROTMAX_FORCE_ENABLE
|
|
|
|
|
.It Dv PROC_PROTMAX_FORCE_DISABLE
|
|
|
|
|
.It Dv PROC_PROTMAX_NOFORCE
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
If the currently executed image in the process itself has the implicit PROT_MAX
|
|
|
|
|
control enabled, the
|
2019-07-02 15:07:17 -04:00
|
|
|
.Dv PROC_PROTMAX_ACTIVE
|
|
|
|
|
flag is or-ed with the value listed above.
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Dv PROC_SPROTECT
|
|
|
|
|
Set process protection state.
|
|
|
|
|
This is used to mark a process as protected from being killed if the system
|
2024-12-04 09:11:19 -05:00
|
|
|
exhausts available memory and swap.
|
2013-09-19 14:53:42 -04:00
|
|
|
The
|
2020-06-13 14:18:34 -04:00
|
|
|
.Fa data
|
2013-09-19 14:53:42 -04:00
|
|
|
parameter must point to an integer containing an operation and zero or more
|
|
|
|
|
optional flags.
|
|
|
|
|
The following operations are supported:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Dv PPROT_SET
|
|
|
|
|
Mark the selected processes as protected.
|
|
|
|
|
.It Dv PPROT_CLEAR
|
|
|
|
|
Clear the protected state of selected processes.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
The following optional flags are supported:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Dv PPROT_DESCEND
|
|
|
|
|
Apply the requested operation to all child processes of each selected process
|
|
|
|
|
in addition to each selected process.
|
|
|
|
|
.It Dv PPROT_INHERIT
|
|
|
|
|
When used with
|
|
|
|
|
.Dv PPROT_SET ,
|
|
|
|
|
mark all future child processes of each selected process as protected.
|
|
|
|
|
Future child processes will also mark all of their future child processes.
|
|
|
|
|
.El
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv PROC_REAP_ACQUIRE
|
2024-12-04 09:11:19 -05:00
|
|
|
Enable orphaned process reaping for future children of the current process.
|
|
|
|
|
.Pp
|
|
|
|
|
If a parent process exits before one or more of its children processes,
|
|
|
|
|
the remaining children processes are orphaned.
|
|
|
|
|
When an orphaned process exits,
|
|
|
|
|
it is reparented to a reaper process that is responsible for harvesting
|
|
|
|
|
the terminated process via
|
|
|
|
|
.Xr wait 2 .
|
|
|
|
|
When this control is enabled,
|
|
|
|
|
the current process becomes the reaper process for future children and their
|
|
|
|
|
descendants.
|
|
|
|
|
Existing child processes continue to use the reaper assigned when the child
|
|
|
|
|
was created via
|
|
|
|
|
.Xr fork 2 .
|
|
|
|
|
If a reaper process exits,
|
|
|
|
|
all of the processes for whom it was the reaper are reassigned to the reaper
|
|
|
|
|
process's reaper.
|
|
|
|
|
.Pp
|
2015-08-20 22:42:14 -04:00
|
|
|
After system initialization,
|
2014-12-15 07:01:42 -05:00
|
|
|
.Xr init 8
|
|
|
|
|
is the default reaper.
|
|
|
|
|
.It Dv PROC_REAP_RELEASE
|
2024-12-04 09:11:19 -05:00
|
|
|
Disable orphaned process reaping for the current process.
|
|
|
|
|
.Pp
|
|
|
|
|
Any processes for whom the current process was the reaper are reassigned to
|
|
|
|
|
the current process's reaper.
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv PROC_REAP_STATUS
|
2024-12-04 09:11:19 -05:00
|
|
|
Provides a consistent snapshot of information about the reaper
|
|
|
|
|
of the specified process,
|
|
|
|
|
or the process itself if it is a reaper.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa data
|
2014-12-16 20:32:27 -05:00
|
|
|
argument must point to a
|
|
|
|
|
.Vt procctl_reaper_status
|
2024-12-04 09:11:19 -05:00
|
|
|
structure which is filled in by the system call on successful return.
|
2014-12-15 07:01:42 -05:00
|
|
|
.Bd -literal
|
|
|
|
|
struct procctl_reaper_status {
|
|
|
|
|
u_int rs_flags;
|
|
|
|
|
u_int rs_children;
|
|
|
|
|
u_int rs_descendants;
|
|
|
|
|
pid_t rs_reaper;
|
|
|
|
|
pid_t rs_pid;
|
|
|
|
|
};
|
|
|
|
|
.Ed
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rs_flags
|
|
|
|
|
may have the following flags returned:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv REAPER_STATUS_OWNED
|
2024-12-04 09:11:19 -05:00
|
|
|
The specified process is a reaper.
|
|
|
|
|
When this flag is returned, the specified process
|
2014-12-16 20:32:27 -05:00
|
|
|
.Fa id ,
|
2024-12-04 09:11:19 -05:00
|
|
|
pid, identifies a reaper, otherwise the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Fa rs_reaper
|
2014-12-16 20:32:27 -05:00
|
|
|
field of the structure is set to the pid of the reaper
|
|
|
|
|
for the specified process id.
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv REAPER_STATUS_REALINIT
|
2015-08-20 22:42:14 -04:00
|
|
|
The specified process is the root of the reaper tree, i.e.,
|
2014-12-16 20:32:27 -05:00
|
|
|
.Xr init 8 .
|
2014-12-15 07:01:42 -05:00
|
|
|
.El
|
2014-12-21 07:36:36 -05:00
|
|
|
.Pp
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rs_children
|
2024-12-04 09:11:19 -05:00
|
|
|
field returns the number of processes that can be reaped by the reaper that
|
|
|
|
|
are also children of the reaper.
|
2015-08-20 22:42:14 -04:00
|
|
|
It is possible to have a child whose reaper is not the specified process,
|
2024-12-04 09:11:19 -05:00
|
|
|
since the reaper for existing children is not changed by
|
|
|
|
|
.Dv PROC_REAP_ACQUIRE .
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rs_descendants
|
2024-12-04 09:11:19 -05:00
|
|
|
field returns the total number of processes that can be reaped by the reaper.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rs_reaper
|
2024-12-04 09:11:19 -05:00
|
|
|
field returns the reaper's pid.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rs_pid
|
2024-12-04 09:11:19 -05:00
|
|
|
returns the pid of one reaper child if there are any processes that can be
|
|
|
|
|
reapead;
|
|
|
|
|
otherwise, it is set to \-1.
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv PROC_REAP_GETPIDS
|
2024-12-04 09:11:19 -05:00
|
|
|
Queries the list of processes that can be reaped
|
|
|
|
|
by the reaper of the specified process.
|
2014-12-16 20:32:27 -05:00
|
|
|
The request takes a pointer to a
|
|
|
|
|
.Vt procctl_reaper_pids
|
|
|
|
|
structure in the
|
|
|
|
|
.Fa data
|
|
|
|
|
parameter.
|
2014-12-15 07:01:42 -05:00
|
|
|
.Bd -literal
|
|
|
|
|
struct procctl_reaper_pids {
|
|
|
|
|
u_int rp_count;
|
|
|
|
|
struct procctl_reaper_pidinfo *rp_pids;
|
|
|
|
|
};
|
|
|
|
|
.Ed
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
2014-12-16 20:32:27 -05:00
|
|
|
When called, the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Fa rp_pids
|
2014-12-16 20:32:27 -05:00
|
|
|
field must point to an array of
|
2014-12-15 07:01:42 -05:00
|
|
|
.Fa rp_count
|
2024-12-04 09:11:19 -05:00
|
|
|
.Vt procctl_reaper_pidinfo
|
|
|
|
|
structures.
|
|
|
|
|
The kernel will populate these structures with information about the
|
|
|
|
|
reaper's descendants.
|
2014-12-15 07:01:42 -05:00
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Vt "struct procctl_reaper_pidinfo"
|
2014-12-16 20:32:27 -05:00
|
|
|
structure provides some information about one of the reaper's descendants.
|
|
|
|
|
Note that for a descendant that is not a child, it may be incorrectly
|
|
|
|
|
identified because of a race in which the original child process exited
|
|
|
|
|
and the exited process's pid was reused for an unrelated process.
|
2014-12-15 07:01:42 -05:00
|
|
|
.Bd -literal
|
|
|
|
|
struct procctl_reaper_pidinfo {
|
|
|
|
|
pid_t pi_pid;
|
|
|
|
|
pid_t pi_subtree;
|
|
|
|
|
u_int pi_flags;
|
|
|
|
|
};
|
|
|
|
|
.Ed
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa pi_pid
|
2014-12-16 20:32:27 -05:00
|
|
|
field is the process id of the descendant.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa pi_subtree
|
2024-12-04 09:11:19 -05:00
|
|
|
field provides the pid of the direct child of the reaper which is
|
|
|
|
|
the (grand-)parent of the descendant process.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa pi_flags
|
2014-12-16 20:32:27 -05:00
|
|
|
field returns the following flags, further describing the descendant:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv REAPER_PIDINFO_VALID
|
2014-12-16 20:32:27 -05:00
|
|
|
Set to indicate that the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Vt procctl_reaper_pidinfo
|
2014-12-16 20:32:27 -05:00
|
|
|
structure was filled in by the kernel.
|
2014-12-15 07:01:42 -05:00
|
|
|
Zero-filling the
|
|
|
|
|
.Fa rp_pids
|
2014-12-16 20:32:27 -05:00
|
|
|
array and testing the
|
|
|
|
|
.Dv REAPER_PIDINFO_VALID
|
|
|
|
|
flag allows the caller to detect the end
|
|
|
|
|
of the returned array.
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv REAPER_PIDINFO_CHILD
|
|
|
|
|
The
|
|
|
|
|
.Fa pi_pid
|
2024-12-04 09:11:19 -05:00
|
|
|
field identifies a direct child of the reaper.
|
2017-11-23 06:25:11 -05:00
|
|
|
.It Dv REAPER_PIDINFO_REAPER
|
|
|
|
|
The reported process is itself a reaper.
|
|
|
|
|
The descendants of the subordinate reaper are not reported.
|
2023-04-15 13:59:30 -04:00
|
|
|
.It Dv REAPER_PIDINFO_ZOMBIE
|
|
|
|
|
The reported process is in the zombie state, ready to be reaped.
|
|
|
|
|
.It Dv REAPER_PIDINFO_STOPPED
|
|
|
|
|
The reported process is stopped by a SIGSTOP/SIGTSTP signal.
|
|
|
|
|
.It Dv REAPER_PIDINFO_EXITING
|
|
|
|
|
The reported process is in the process of exiting (but not yet a zombie).
|
2014-12-15 07:01:42 -05:00
|
|
|
.El
|
|
|
|
|
.It Dv PROC_REAP_KILL
|
2014-12-16 20:32:27 -05:00
|
|
|
Request to deliver a signal to some subset of the descendants of the reaper.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa data
|
2014-12-16 20:32:27 -05:00
|
|
|
parameter must point to a
|
2014-12-15 07:01:42 -05:00
|
|
|
.Vt procctl_reaper_kill
|
|
|
|
|
structure, which is used both for parameters and status return.
|
|
|
|
|
.Bd -literal
|
|
|
|
|
struct procctl_reaper_kill {
|
|
|
|
|
int rk_sig;
|
|
|
|
|
u_int rk_flags;
|
|
|
|
|
pid_t rk_subtree;
|
|
|
|
|
u_int rk_killed;
|
|
|
|
|
pid_t rk_fpid;
|
|
|
|
|
};
|
|
|
|
|
.Ed
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rk_sig
|
2014-12-16 20:32:27 -05:00
|
|
|
field specifies the signal to be delivered.
|
2015-08-20 22:42:14 -04:00
|
|
|
Zero is not a valid signal number, unlike for
|
2014-12-15 07:01:42 -05:00
|
|
|
.Xr kill 2 .
|
|
|
|
|
The
|
|
|
|
|
.Fa rk_flags
|
2014-12-16 20:32:27 -05:00
|
|
|
field further directs the operation.
|
2014-12-15 07:01:42 -05:00
|
|
|
It is or-ed from the following flags:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Dv REAPER_KILL_CHILDREN
|
|
|
|
|
Deliver the specified signal only to direct children of the reaper.
|
|
|
|
|
.It Dv REAPER_KILL_SUBTREE
|
2014-12-16 20:32:27 -05:00
|
|
|
Deliver the specified signal only to descendants that were forked by
|
|
|
|
|
the direct child with pid specified in the
|
|
|
|
|
.Fa rk_subtree
|
|
|
|
|
field.
|
2014-12-15 07:01:42 -05:00
|
|
|
.El
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
2014-12-16 20:32:27 -05:00
|
|
|
If neither the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv REAPER_KILL_CHILDREN
|
2014-12-16 20:32:27 -05:00
|
|
|
nor the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv REAPER_KILL_SUBTREE
|
|
|
|
|
flags are specified, all current descendants of the reaper are signalled.
|
|
|
|
|
.Pp
|
2014-12-16 20:32:27 -05:00
|
|
|
If a signal was delivered to any process, the return value from the request
|
2014-12-15 07:01:42 -05:00
|
|
|
is zero.
|
2014-12-16 20:32:27 -05:00
|
|
|
In this case, the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Fa rk_killed
|
2014-12-16 20:32:27 -05:00
|
|
|
field identifies the number of processes signalled.
|
2014-12-15 07:01:42 -05:00
|
|
|
The
|
|
|
|
|
.Fa rk_fpid
|
|
|
|
|
field is set to the pid of the first process for which signal
|
2015-08-20 22:42:14 -04:00
|
|
|
delivery failed, e.g., due to permission problems.
|
|
|
|
|
If no such process exists, the
|
2014-12-15 07:01:42 -05:00
|
|
|
.Fa rk_fpid
|
2024-12-04 09:11:19 -05:00
|
|
|
field is set to \-1.
|
2015-01-18 10:13:11 -05:00
|
|
|
.It Dv PROC_TRACE_CTL
|
|
|
|
|
Enable or disable tracing of the specified process(es), according to the
|
|
|
|
|
value of the integer argument.
|
2024-12-04 09:11:19 -05:00
|
|
|
Tracing includes inspecting the process via
|
|
|
|
|
.Xr ptrace 2 ,
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr ktrace 2 ,
|
|
|
|
|
debugging sysctls,
|
|
|
|
|
.Xr hwpmc 4 ,
|
2024-12-04 09:11:19 -05:00
|
|
|
or
|
|
|
|
|
.Xr dtrace 1
|
|
|
|
|
as well as dumping core.
|
2015-01-18 10:13:11 -05:00
|
|
|
Possible values for the
|
|
|
|
|
.Fa data
|
|
|
|
|
argument are:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2015-01-18 10:13:11 -05:00
|
|
|
.It Dv PROC_TRACE_CTL_ENABLE
|
|
|
|
|
Enable tracing, after it was disabled by
|
|
|
|
|
.Dv PROC_TRACE_CTL_DISABLE .
|
|
|
|
|
Only allowed for self.
|
|
|
|
|
.It Dv PROC_TRACE_CTL_DISABLE
|
|
|
|
|
Disable tracing for the specified process.
|
|
|
|
|
Tracing is re-enabled when the process changes the executing
|
2015-08-20 22:42:14 -04:00
|
|
|
program with the
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr execve 2
|
2024-12-04 09:11:19 -05:00
|
|
|
system call.
|
2015-01-18 10:13:11 -05:00
|
|
|
A child inherits the trace settings from the parent on
|
|
|
|
|
.Xr fork 2 .
|
|
|
|
|
.It Dv PROC_TRACE_CTL_DISABLE_EXEC
|
|
|
|
|
Same as
|
|
|
|
|
.Dv PROC_TRACE_CTL_DISABLE ,
|
2015-08-20 22:42:14 -04:00
|
|
|
but the setting persists for the process even after
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr execve 2 .
|
|
|
|
|
.El
|
|
|
|
|
.It Dv PROC_TRACE_STATUS
|
|
|
|
|
Returns the current tracing status for the specified process in
|
|
|
|
|
the integer variable pointed to by
|
|
|
|
|
.Fa data .
|
|
|
|
|
If tracing is disabled,
|
|
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
is set to \-1.
|
2015-08-20 22:42:14 -04:00
|
|
|
If tracing is enabled, but no debugger is attached by the
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr ptrace 2
|
2024-12-04 09:11:19 -05:00
|
|
|
system call,
|
2015-01-18 10:13:11 -05:00
|
|
|
.Fa data
|
|
|
|
|
is set to 0.
|
|
|
|
|
If a debugger is attached,
|
|
|
|
|
.Fa data
|
|
|
|
|
is set to the pid of the debugger process.
|
2016-09-23 05:26:40 -04:00
|
|
|
.It Dv PROC_TRAPCAP_CTL
|
2016-09-27 07:31:53 -04:00
|
|
|
Controls the capability mode sandbox actions for the specified
|
2024-12-04 09:11:19 -05:00
|
|
|
sandboxed processes
|
|
|
|
|
on a return from any system call which fails with either an
|
2016-09-23 05:26:40 -04:00
|
|
|
.Er ENOTCAPABLE
|
|
|
|
|
or
|
|
|
|
|
.Er ECAPMODE
|
|
|
|
|
error.
|
2024-12-04 09:11:19 -05:00
|
|
|
If this control is enabled and a system call fails with one of these errors,
|
|
|
|
|
a synchronous
|
2016-09-27 07:31:53 -04:00
|
|
|
.Dv SIGTRAP
|
2024-12-04 09:11:19 -05:00
|
|
|
signal is delivered to the thread immediately before returning from the
|
|
|
|
|
system call.
|
2016-09-23 05:26:40 -04:00
|
|
|
.Pp
|
|
|
|
|
Possible values for the
|
|
|
|
|
.Fa data
|
|
|
|
|
argument are:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2016-09-23 05:26:40 -04:00
|
|
|
.It Dv PROC_TRAPCAP_CTL_ENABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Enable
|
2016-09-23 05:26:40 -04:00
|
|
|
.Dv SIGTRAP
|
|
|
|
|
signal delivery on capability mode access violations.
|
|
|
|
|
The enabled mode is inherited by the children of the process,
|
|
|
|
|
and is kept after
|
|
|
|
|
.Xr fexecve 2
|
|
|
|
|
calls.
|
|
|
|
|
.It Dv PROC_TRAPCAP_CTL_DISABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Disable
|
|
|
|
|
.Dv SIGTRAP
|
|
|
|
|
signal delivery on capability mode access violations.
|
2016-09-23 05:26:40 -04:00
|
|
|
Note that the global sysctl
|
2017-03-16 09:19:38 -04:00
|
|
|
.Dv kern.trap_enotcap
|
2016-09-27 07:31:53 -04:00
|
|
|
might still cause the signal to be delivered.
|
|
|
|
|
See
|
2016-09-23 05:26:40 -04:00
|
|
|
.Xr capsicum 4 .
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
On signal delivery, the
|
|
|
|
|
.Va si_errno
|
|
|
|
|
member of the
|
|
|
|
|
.Fa siginfo
|
2024-12-04 09:11:19 -05:00
|
|
|
signal handler parameter is set to the system call error value,
|
2016-09-23 05:26:40 -04:00
|
|
|
and the
|
|
|
|
|
.Va si_code
|
|
|
|
|
member is set to
|
|
|
|
|
.Dv TRAP_CAP .
|
2021-07-10 12:19:52 -04:00
|
|
|
The system call number is stored in the
|
|
|
|
|
.Va si_syscall
|
|
|
|
|
field of the
|
|
|
|
|
.Fa siginfo
|
|
|
|
|
signal handler parameter.
|
|
|
|
|
The other system call parameters can be read from the
|
|
|
|
|
.Fa ucontext_t
|
|
|
|
|
but the system call number is typically stored in the register
|
|
|
|
|
that also contains the return value and so is unavailable in the
|
|
|
|
|
signal handler.
|
2016-09-23 05:26:40 -04:00
|
|
|
.Pp
|
|
|
|
|
See
|
|
|
|
|
.Xr capsicum 4
|
2024-12-04 09:11:19 -05:00
|
|
|
for more information about capability mode.
|
2016-09-23 05:26:40 -04:00
|
|
|
.It Dv PROC_TRAPCAP_STATUS
|
2024-12-04 09:11:19 -05:00
|
|
|
Return the current status of raising
|
|
|
|
|
.Dv SIGTRAP
|
|
|
|
|
for capability mode access violations by the specified process.
|
2016-09-23 05:26:40 -04:00
|
|
|
The integer value pointed to by the
|
|
|
|
|
.Fa data
|
|
|
|
|
argument is set to the
|
|
|
|
|
.Dv PROC_TRAPCAP_CTL_ENABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
value if
|
|
|
|
|
.Dv SIGTRAP
|
|
|
|
|
delivery is enabled, and to
|
2016-09-23 05:26:40 -04:00
|
|
|
.Dv PROC_TRAPCAP_CTL_DISABLE
|
|
|
|
|
otherwise.
|
|
|
|
|
.Pp
|
|
|
|
|
See the note about sysctl
|
2017-03-16 09:19:38 -04:00
|
|
|
.Dv kern.trap_enotcap
|
2016-09-23 05:26:40 -04:00
|
|
|
above, which gives independent global control of signal delivery.
|
2018-04-20 11:19:27 -04:00
|
|
|
.It Dv PROC_PDEATHSIG_CTL
|
2018-04-18 17:31:13 -04:00
|
|
|
Request the delivery of a signal when the parent of the calling
|
|
|
|
|
process exits.
|
|
|
|
|
.Fa idtype
|
|
|
|
|
must be
|
|
|
|
|
.Dv P_PID
|
|
|
|
|
and
|
|
|
|
|
.Fa id
|
|
|
|
|
must be the either caller's pid or zero, with no difference in effect.
|
|
|
|
|
The value is cleared for child processes
|
|
|
|
|
and when executing set-user-ID or set-group-ID binaries.
|
2020-07-11 14:04:09 -04:00
|
|
|
.Fa data
|
2018-04-18 17:31:13 -04:00
|
|
|
must point to a value of type
|
|
|
|
|
.Vt int
|
|
|
|
|
indicating the signal
|
|
|
|
|
that should be delivered to the caller.
|
|
|
|
|
Use zero to cancel a previously requested signal delivery.
|
2018-04-20 11:19:27 -04:00
|
|
|
.It Dv PROC_PDEATHSIG_STATUS
|
2018-04-18 17:31:13 -04:00
|
|
|
Query the current signal number that will be delivered when the parent
|
|
|
|
|
of the calling process exits.
|
|
|
|
|
.Fa idtype
|
|
|
|
|
must be
|
|
|
|
|
.Dv P_PID
|
|
|
|
|
and
|
|
|
|
|
.Fa id
|
|
|
|
|
must be the either caller's pid or zero, with no difference in effect.
|
2020-07-11 14:04:09 -04:00
|
|
|
.Fa data
|
2018-04-18 17:31:13 -04:00
|
|
|
must point to a memory location that can hold a value of type
|
|
|
|
|
.Vt int .
|
|
|
|
|
If signal delivery has not been requested, it will contain zero
|
|
|
|
|
on return.
|
2019-09-03 14:56:25 -04:00
|
|
|
.It Dv PROC_STACKGAP_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
Controls stack gaps in the specified process.
|
|
|
|
|
A stack gap is one or more virtual memory pages at the end of the
|
|
|
|
|
growth area for a
|
2019-09-03 14:56:25 -04:00
|
|
|
.Dv MAP_STACK
|
2024-12-04 09:11:19 -05:00
|
|
|
mapping that is reserved and never backed by memory.
|
|
|
|
|
Instead, the process is guaranteed to receive a synchronous
|
2019-09-03 14:56:25 -04:00
|
|
|
.Dv SIGSEGV
|
2024-12-04 09:11:19 -05:00
|
|
|
signal for each access to pages in the gap.
|
|
|
|
|
The number of pages reserved for each stack is set by the sysctl
|
|
|
|
|
.Va security.bsd.stack_guard_page .
|
|
|
|
|
.Pp
|
|
|
|
|
Gaps protect against stack overflows by preventing them from corrupting memory
|
|
|
|
|
adjacent to the stack.
|
2019-09-03 14:56:25 -04:00
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fa data
|
|
|
|
|
argument must point to an integer variable containing flags.
|
|
|
|
|
The following flags are allowed:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-09-03 14:56:25 -04:00
|
|
|
.It Dv PROC_STACKGAP_ENABLE
|
|
|
|
|
This flag is only accepted for consistency with
|
|
|
|
|
.Dv PROC_STACKGAP_STATUS .
|
|
|
|
|
If stack gaps are enabled, the flag is ignored.
|
2024-12-04 09:11:19 -05:00
|
|
|
If stack gaps are disabled, the request fails with
|
|
|
|
|
.Ev EINVAL .
|
2019-09-03 14:56:25 -04:00
|
|
|
After gaps are disabled in a process, they can only be re-enabled when an
|
|
|
|
|
.Xr execve 2
|
|
|
|
|
is performed.
|
|
|
|
|
.It Dv PROC_STACKGAP_DISABLE
|
|
|
|
|
Disable stack gaps for the process.
|
2024-12-04 09:11:19 -05:00
|
|
|
For existing stacks, the gap is no longer reserved
|
|
|
|
|
and can be filled by memory on access.
|
2019-09-03 14:56:25 -04:00
|
|
|
.It Dv PROC_STACKGAP_ENABLE_EXEC
|
2024-12-04 09:11:19 -05:00
|
|
|
Enable stack gaps for the new address space constructed by any future
|
2019-09-03 14:56:25 -04:00
|
|
|
.Xr execve 2
|
2024-12-04 09:11:19 -05:00
|
|
|
in the specified process.
|
2019-09-03 14:56:25 -04:00
|
|
|
.It Dv PROC_STACKGAP_DISABLE_EXEC
|
|
|
|
|
Inherit disabled stack gaps state after
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
In other words, if the currently executing program has stack gaps disabled,
|
|
|
|
|
they are kept disabled on exec.
|
|
|
|
|
If gaps were enabled, they are kept enabled after exec.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
The stack gap state is inherited from the parent on
|
|
|
|
|
.Xr fork 2 .
|
|
|
|
|
.It Dv PROC_STACKGAP_STATUS
|
|
|
|
|
Returns the current stack gap state for the specified process.
|
|
|
|
|
.Fa data
|
|
|
|
|
must point to an integer variable, which is used to return a bitmask
|
|
|
|
|
consisting of the following flags:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2019-09-03 14:56:25 -04:00
|
|
|
.It Dv PROC_STACKGAP_ENABLE
|
|
|
|
|
Stack gaps are enabled.
|
|
|
|
|
.It Dv PROC_STACKGAP_DISABLE
|
|
|
|
|
Stack gaps are disabled.
|
|
|
|
|
.It Dv PROC_STACKGAP_ENABLE_EXEC
|
|
|
|
|
Stack gaps are enabled in the process after
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
.It Dv PROC_STACKGAP_DISABLE_EXEC
|
|
|
|
|
Stack gaps are disabled in the process after
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
.El
|
2024-12-04 09:11:19 -05:00
|
|
|
.Pp
|
|
|
|
|
Note that the
|
|
|
|
|
.Xr elfctl 1
|
|
|
|
|
.Dq nostackgap
|
|
|
|
|
flag takes precedence over this setting for individual process address spaces.
|
|
|
|
|
Executing a binary with this flag set will never use stack gaps in the address
|
|
|
|
|
space constructed by
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
However, the controls value can still be inherited by child processes, and
|
|
|
|
|
executing a binary without this flag set will revert to the behavior specified
|
|
|
|
|
by the control.
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
.It Dv PROC_NO_NEW_PRIVS_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
Allows one to ignore the set-user-ID and set-group-ID bits on the program
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
images activated by
|
|
|
|
|
.Xr execve 2
|
|
|
|
|
in the specified process and its future descendants.
|
|
|
|
|
The
|
|
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable holding the following
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
value:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
.It Dv PROC_NO_NEW_PRIVS_ENABLE
|
2024-12-04 09:11:19 -05:00
|
|
|
Request set-user-ID and set-group-ID bits to be ignored.
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
.El
|
|
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
It is not possible to disable this control once it has been enabled.
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
.It Dv PROC_NO_NEW_PRIVS_STATUS
|
2024-12-04 09:11:19 -05:00
|
|
|
Returns the current status of set-ID bits enablement for the target process.
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
The
|
|
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable, where one of the
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
following values is written:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared. The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.
The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939
2021-07-01 04:11:11 -04:00
|
|
|
.It Dv PROC_NO_NEW_PRIVS_ENABLE
|
|
|
|
|
.It Dv PROC_NO_NEW_PRIVS_DISABLE
|
|
|
|
|
.El
|
2021-09-01 20:59:10 -04:00
|
|
|
.It Dv PROC_WXMAP_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
Controls the creation of mappings with both write and execute permissions
|
|
|
|
|
in a process's address space.
|
2021-09-01 20:59:10 -04:00
|
|
|
The
|
|
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable holding one of the
|
2021-09-01 20:59:10 -04:00
|
|
|
following values:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2021-09-01 20:59:10 -04:00
|
|
|
.It Dv PROC_WX_MAPPINGS_PERMIT
|
|
|
|
|
Enable creation of mappings that have both write and execute
|
2024-12-04 09:11:19 -05:00
|
|
|
permissions in the specified process' current and future address spaces.
|
2021-09-01 20:59:10 -04:00
|
|
|
.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
|
2024-12-04 09:11:19 -05:00
|
|
|
In a new address space created by a future call to
|
2021-09-01 20:59:10 -04:00
|
|
|
.Xr execve 2 ,
|
|
|
|
|
disallow creation of mappings that have both write and execute
|
|
|
|
|
permissions.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
If both flags are set,
|
|
|
|
|
.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
|
|
|
|
|
takes precedence during
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
If neither flag is set,
|
|
|
|
|
mappings with write and execute permissions are only permitted if the
|
|
|
|
|
.Dv kern.elf{32/64}.allow_wx
|
|
|
|
|
sysctl is non-zero or the
|
|
|
|
|
.Xr elfctl 1
|
|
|
|
|
.Dq wxneeded
|
|
|
|
|
flag is set in the ELF control note.
|
|
|
|
|
.Pp
|
|
|
|
|
Once creation of writeable and executable mappings is enabled for a process,
|
|
|
|
|
it is impossible (and pointless) to disable it.
|
2021-09-01 20:59:10 -04:00
|
|
|
The only way to ensure the absence of such mappings after they
|
2024-12-04 09:11:19 -05:00
|
|
|
were enabled in a given process is to set the
|
2021-09-01 20:59:10 -04:00
|
|
|
.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
|
|
|
|
|
flag and
|
|
|
|
|
.Xr execve 2
|
|
|
|
|
an image.
|
|
|
|
|
.It Dv PROC_WXMAP_STATUS
|
2024-12-04 09:11:19 -05:00
|
|
|
Returns the current status of the controls over creation of mappings with
|
|
|
|
|
both write and execute permissions for the specified process.
|
2021-09-01 20:59:10 -04:00
|
|
|
The
|
|
|
|
|
.Dv data
|
2024-12-04 09:11:19 -05:00
|
|
|
parameter must point to an integer variable, where one of the
|
2021-09-01 20:59:10 -04:00
|
|
|
following values is written:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2021-09-01 20:59:10 -04:00
|
|
|
.It Dv PROC_WX_MAPPINGS_PERMIT
|
2024-12-04 09:11:19 -05:00
|
|
|
Creation of simultaneously writable and executable mappings are permitted;
|
|
|
|
|
otherwise, the process cannot create such mappings.
|
2021-09-01 20:59:10 -04:00
|
|
|
.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
|
|
|
|
|
After
|
|
|
|
|
.Xr execve 2 ,
|
2024-12-04 09:11:19 -05:00
|
|
|
the new address space will not permit creation of simultaneously
|
2021-09-01 20:59:10 -04:00
|
|
|
writable and executable mappings.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
Additionally, if the address space of the process does not permit
|
2021-09-01 20:59:10 -04:00
|
|
|
creation of simultaneously writable and executable mappings and
|
|
|
|
|
it is guaranteed that no such mapping was created since address space
|
|
|
|
|
creation, the
|
|
|
|
|
.Dv PROC_WXORX_ENFORCE
|
|
|
|
|
flag is set in the returned value.
|
2013-09-19 14:53:42 -04:00
|
|
|
.El
|
2020-06-13 14:19:42 -04:00
|
|
|
.Sh x86 MACHINE-SPECIFIC REQUESTS
|
|
|
|
|
.Bl -tag -width PROC_KPTI_STATUS
|
|
|
|
|
.It Dv PROC_KPTI_CTL
|
|
|
|
|
AMD64 only.
|
|
|
|
|
Controls the Kernel Page Table Isolation (KPTI) option for the children
|
|
|
|
|
of the specified process.
|
2024-12-04 09:11:19 -05:00
|
|
|
This control is only meaningful if KPTI has been enabled globally by the
|
2020-06-13 14:19:42 -04:00
|
|
|
.Va vm.pmap.kpti
|
2024-12-04 09:11:19 -05:00
|
|
|
tunable.
|
2020-06-13 14:19:42 -04:00
|
|
|
It is not possible to change the KPTI setting for a running process,
|
2024-12-04 09:11:19 -05:00
|
|
|
only for new address spaces constructed by a future
|
|
|
|
|
.Xr execve 2 .
|
2020-06-13 14:19:42 -04:00
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fa data
|
|
|
|
|
parameter must point to an integer variable containing one of the
|
|
|
|
|
following commands:
|
2024-12-04 09:11:19 -05:00
|
|
|
.Bl -tag -width Ds
|
2020-06-13 14:19:42 -04:00
|
|
|
.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
|
|
|
|
|
Enable KPTI after
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
|
|
|
|
|
Disable KPTI after
|
|
|
|
|
.Xr execve 2 .
|
|
|
|
|
Only root or a process having the
|
|
|
|
|
.Va PRIV_IO
|
2024-12-04 09:11:19 -05:00
|
|
|
privilege can use this option.
|
2020-06-13 14:19:42 -04:00
|
|
|
.El
|
|
|
|
|
.It Dv PROC_KPTI_STATUS
|
|
|
|
|
Returns the current KPTI status for the specified process.
|
2020-07-11 14:04:09 -04:00
|
|
|
.Fa data
|
2024-12-04 09:11:19 -05:00
|
|
|
must point to an integer variable, where one of the
|
|
|
|
|
following values is written:
|
|
|
|
|
.Bl -tag -width Ds
|
2020-06-13 14:19:42 -04:00
|
|
|
.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
|
|
|
|
|
.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
The status is or-ed with
|
2020-06-13 14:19:42 -04:00
|
|
|
.Va PROC_KPTI_STATUS_ACTIVE
|
2024-12-04 09:11:19 -05:00
|
|
|
if KPTI is active for the current address space of the process.
|
2024-09-19 21:54:39 -04:00
|
|
|
.El
|
2015-01-18 10:13:11 -05:00
|
|
|
.Sh NOTES
|
|
|
|
|
Disabling tracing on a process should not be considered a security
|
2024-12-04 09:11:19 -05:00
|
|
|
feature, as it is bypassable both by the kernel and privileged processes
|
2015-01-18 10:13:11 -05:00
|
|
|
and via other system mechanisms.
|
2015-08-20 22:42:14 -04:00
|
|
|
As such, it should not be utilized to reliably protect cryptographic
|
2015-01-18 10:13:11 -05:00
|
|
|
keying material or other confidential data.
|
2021-09-01 20:59:10 -04:00
|
|
|
.Pp
|
|
|
|
|
Note that processes can trivially bypass the 'no simultaneously
|
|
|
|
|
writable and executable mappings' policy by first marking some mapping
|
2024-12-04 09:11:19 -05:00
|
|
|
as writeable, writing code to it, then removing write and adding
|
2021-09-01 20:59:10 -04:00
|
|
|
execute permission.
|
2024-12-04 09:11:19 -05:00
|
|
|
This may be legitimately required by some programs such as JIT compilers.
|
2013-09-19 14:53:42 -04:00
|
|
|
.Sh RETURN VALUES
|
2024-12-04 09:11:19 -05:00
|
|
|
If an error occurs, a value of \-1 is returned and
|
2013-09-19 14:53:42 -04:00
|
|
|
.Va errno
|
|
|
|
|
is set to indicate the error.
|
|
|
|
|
.Sh ERRORS
|
|
|
|
|
The
|
|
|
|
|
.Fn procctl
|
|
|
|
|
system call
|
|
|
|
|
will fail if:
|
|
|
|
|
.Bl -tag -width Er
|
|
|
|
|
.It Bq Er EFAULT
|
|
|
|
|
The
|
2020-07-11 14:04:09 -04:00
|
|
|
.Fa data
|
2014-12-16 20:32:27 -05:00
|
|
|
parameter points outside the process's allocated address space.
|
2013-09-19 14:53:42 -04:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
|
The
|
|
|
|
|
.Fa cmd
|
|
|
|
|
argument specifies an unsupported command.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fa idtype
|
|
|
|
|
argument specifies an unsupported identifier type.
|
|
|
|
|
.It Bq Er EPERM
|
|
|
|
|
The calling process does not have permission to perform the requested
|
|
|
|
|
operation on any of the selected processes.
|
|
|
|
|
.It Bq Er ESRCH
|
|
|
|
|
No processes matched the requested
|
|
|
|
|
.Fa idtype
|
|
|
|
|
and
|
|
|
|
|
.Fa id .
|
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
|
An invalid operation or flag was passed in
|
2020-07-11 14:04:09 -04:00
|
|
|
.Fa data
|
2013-09-19 14:53:42 -04:00
|
|
|
for a
|
|
|
|
|
.Dv PROC_SPROTECT
|
|
|
|
|
command.
|
2014-12-15 07:01:42 -05:00
|
|
|
.It Bq Er EPERM
|
|
|
|
|
The
|
|
|
|
|
.Fa idtype
|
|
|
|
|
argument is not equal to
|
|
|
|
|
.Dv P_PID ,
|
|
|
|
|
or
|
|
|
|
|
.Fa id
|
|
|
|
|
is not equal to the pid of the calling process, for
|
|
|
|
|
.Dv PROC_REAP_ACQUIRE
|
|
|
|
|
or
|
|
|
|
|
.Dv PROC_REAP_RELEASE
|
|
|
|
|
requests.
|
|
|
|
|
.It Bq Er EINVAL
|
2014-12-16 20:32:27 -05:00
|
|
|
Invalid or undefined flags were passed to a
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv PROC_REAP_KILL
|
|
|
|
|
request.
|
|
|
|
|
.It Bq Er EINVAL
|
2014-12-16 20:32:27 -05:00
|
|
|
An invalid or zero signal number was requested for a
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv PROC_REAP_KILL
|
|
|
|
|
request.
|
|
|
|
|
.It Bq Er EINVAL
|
2024-12-04 09:11:19 -05:00
|
|
|
A
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv PROC_REAP_RELEASE
|
|
|
|
|
request was issued by the
|
|
|
|
|
.Xr init 8
|
|
|
|
|
process.
|
|
|
|
|
.It Bq Er EBUSY
|
2024-12-04 09:11:19 -05:00
|
|
|
A
|
2014-12-15 07:01:42 -05:00
|
|
|
.Dv PROC_REAP_ACQUIRE
|
2024-12-04 09:11:19 -05:00
|
|
|
request was issued by a process that is already a reaper process.
|
2015-01-18 10:13:11 -05:00
|
|
|
.It Bq Er EBUSY
|
2024-12-04 09:11:19 -05:00
|
|
|
A
|
2015-01-18 10:13:11 -05:00
|
|
|
.Dv PROC_TRACE_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
request was issued for a process being traced.
|
2015-01-18 10:13:11 -05:00
|
|
|
.It Bq Er EPERM
|
2024-12-04 09:11:19 -05:00
|
|
|
A
|
2015-01-18 10:13:11 -05:00
|
|
|
.Dv PROC_TRACE_CTL
|
2015-08-20 22:42:14 -04:00
|
|
|
request to re-enable tracing of the process
|
|
|
|
|
.Po Dv PROC_TRACE_CTL_ENABLE Pc ,
|
|
|
|
|
or to disable persistence of
|
2015-01-18 10:13:11 -05:00
|
|
|
.Dv PROC_TRACE_CTL_DISABLE
|
|
|
|
|
on
|
|
|
|
|
.Xr execve 2
|
2024-12-04 09:11:19 -05:00
|
|
|
specified a target process other than the calling process.
|
2015-01-18 10:13:11 -05:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
|
The value of the integer
|
|
|
|
|
.Fa data
|
|
|
|
|
parameter for the
|
|
|
|
|
.Dv PROC_TRACE_CTL
|
2016-09-23 05:26:40 -04:00
|
|
|
or
|
|
|
|
|
.Dv PROC_TRAPCAP_CTL
|
2015-01-18 10:13:11 -05:00
|
|
|
request is invalid.
|
2018-04-18 17:31:13 -04:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
|
The
|
2018-04-20 11:19:27 -04:00
|
|
|
.Dv PROC_PDEATHSIG_CTL
|
2018-04-18 17:31:13 -04:00
|
|
|
or
|
2018-04-20 11:19:27 -04:00
|
|
|
.Dv PROC_PDEATHSIG_STATUS
|
2018-04-18 17:31:13 -04:00
|
|
|
request referenced an unsupported
|
|
|
|
|
.Fa id ,
|
|
|
|
|
.Fa idtype
|
|
|
|
|
or invalid signal number.
|
2013-09-19 14:53:42 -04:00
|
|
|
.El
|
|
|
|
|
.Sh SEE ALSO
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr dtrace 1 ,
|
2024-12-04 09:11:19 -05:00
|
|
|
.Xr elfctl 1 ,
|
2019-04-09 06:09:59 -04:00
|
|
|
.Xr proccontrol 1 ,
|
|
|
|
|
.Xr protect 1 ,
|
2020-04-24 18:04:14 -04:00
|
|
|
.Xr cap_enter 2 ,
|
2014-12-15 07:01:42 -05:00
|
|
|
.Xr kill 2 ,
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr ktrace 2 ,
|
2019-07-02 15:07:17 -04:00
|
|
|
.Xr mmap 2 ,
|
|
|
|
|
.Xr mprotect 2 ,
|
2014-12-15 07:01:42 -05:00
|
|
|
.Xr ptrace 2 ,
|
|
|
|
|
.Xr wait 2 ,
|
2016-09-23 05:26:40 -04:00
|
|
|
.Xr capsicum 4 ,
|
2015-01-18 10:13:11 -05:00
|
|
|
.Xr hwpmc 4 ,
|
2014-12-15 07:01:42 -05:00
|
|
|
.Xr init 8
|
2013-09-19 14:53:42 -04:00
|
|
|
.Sh HISTORY
|
|
|
|
|
The
|
|
|
|
|
.Fn procctl
|
|
|
|
|
function appeared in
|
2014-01-28 16:40:10 -05:00
|
|
|
.Fx 10.0 .
|
2019-02-26 12:41:41 -05:00
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
The reaper facility is based on a similar feature in Linux and
|
2014-12-15 07:01:42 -05:00
|
|
|
DragonflyBSD, and first appeared in
|
|
|
|
|
.Fx 10.2 .
|
2019-02-26 12:41:41 -05:00
|
|
|
.Pp
|
2018-04-18 17:31:13 -04:00
|
|
|
The
|
2018-04-20 11:19:27 -04:00
|
|
|
.Dv PROC_PDEATHSIG_CTL
|
2024-12-04 09:11:19 -05:00
|
|
|
facility is based on the
|
|
|
|
|
.Ql prctl(PR_SET_PDEATHSIG, ...)
|
|
|
|
|
feature in Linux,
|
2018-04-18 17:31:13 -04:00
|
|
|
and first appeared in
|
2018-05-12 06:11:33 -04:00
|
|
|
.Fx 11.2 .
|
2019-02-26 12:41:41 -05:00
|
|
|
.Pp
|
2024-12-04 09:11:19 -05:00
|
|
|
ASLR support was added for checklist compliance in
|
2019-02-26 12:41:41 -05:00
|
|
|
.Fx 13.0 .
|