xref: /openbsd/share/man/man7/securelevel.7 (revision 09467b48)
1.\"     $OpenBSD: securelevel.7,v 1.31 2019/08/21 20:44:09 cheloha Exp $
2.\"
3.\" Copyright (c) 2000 Hugh Graham
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15.\" WARRANTIES, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
22.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24.\" POSSIBILITY OF SUCH DAMAGE.
25.\"
26.Dd $Mdocdate: August 21 2019 $
27.Dt SECURELEVEL 7
28.Os
29.Sh NAME
30.Nm securelevel
31.Nd securelevel and its effects
32.Sh DESCRIPTION
33The
34.Ox
35kernel provides four levels of system security:
36.Bl -tag -width flag
37.It \&-1 Em Permanently insecure mode
38.Bl -hyphen -compact
39.It
40.Xr init 8
41will not attempt to raise the securelevel
42.It
43may only be set with
44.Xr sysctl 8
45while the system is insecure
46.It
47otherwise identical to securelevel 0
48.El
49.It \ 0 Em Insecure mode
50.Bl -hyphen -compact
51.It
52used during bootstrapping and while the system is single-user
53.It
54all devices may be read or written subject to their permissions
55.It
56system file flags may be cleared with
57.Xr chflags 2
58.El
59.It \ 1 Em Secure mode
60.Bl -hyphen -compact
61.It
62default mode when system is multi-user
63.It
64securelevel may no longer be lowered except by init
65.It
66.Pa /dev/mem
67and
68.Pa /dev/kmem
69cannot be opened
70.It
71raw disk devices of mounted file systems are read-only
72.It
73system immutable and append-only file flags may not be removed
74.It
75the
76.Va fs.posix.setuid ,
77.Va hw.allowpowerdown ,
78.Va kern.allowkmem ,
79.Va kern.utc_offset ,
80.Va net.inet.ip.sourceroute ,
81and
82.Va machdep.kbdreset
83.Xr sysctl 8
84variables may not be changed
85.It
86the
87.Va ddb.console ,
88.Va ddb.panic ,
89and
90.Va machdep.allowaperture
91.Xr sysctl 8
92variables may not be raised
93.It
94.Xr gpioctl 8
95may only access GPIO pins configured at system startup
96.El
97.It \ 2 Em Highly secure mode
98.Bl -hyphen -compact
99.It
100all effects of securelevel 1
101.It
102raw disk devices are always read-only whether mounted or not
103.It
104.Xr settimeofday 2
105and
106.Xr clock_settime 2
107may not set the time backwards or close to overflow
108.It
109.Xr pf 4
110filter and NAT rules may not be altered
111.El
112.El
113.Pp
114Securelevel provides convenient means of
115.Dq locking down
116a system to a degree suited to its environment.
117It is normally set at boot by
118.Xr rc 8 ,
119or the superuser may raise securelevel at any time by modifying the
120.Va kern.securelevel
121.Xr sysctl 8
122variable.
123However, only
124.Xr init 8
125may lower it once the system has entered secure mode.
126.Pp
127Highly secure mode may seem Draconian, but is intended as a last line of
128defence should the superuser account be compromised.
129Its effects preclude
130circumvention of file flags by direct modification of a raw disk device,
131or erasure of a file system by means of
132.Xr newfs 8 .
133Further, it can limit the potential damage of a compromised
134.Dq firewall
135by prohibiting the modification of packet filter rules.
136Preventing
137the system clock from being set backwards aids in post-mortem analysis
138and helps ensure the integrity of logs.
139Precision timekeeping is not
140affected because the clock may still be slowed.
141.Pp
142Because securelevel can be modified with the in-kernel debugger
143.Xr ddb 4 ,
144a convenient means of locking it off (if present) is provided
145at securelevels 1 and 2.
146This is accomplished by setting
147.Va ddb.console
148and
149.Va ddb.panic
150to 0 with the
151.Xr sysctl 8
152utility.
153.Sh FILES
154.Bl -tag -width /etc/rc.securelevel -compact
155.It Pa /etc/rc.securelevel
156commands that run before the security level changes
157.El
158.Sh SEE ALSO
159.Xr init 8 ,
160.Xr rc 8 ,
161.Xr sysctl 8
162.Sh HISTORY
163The
164.Nm
165manual page first appeared in
166.Ox 2.6 .
167.Sh BUGS
168The list of securelevel's effects may not be comprehensive.
169