]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/sys/cap_enter.2
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / sys / cap_enter.2
1 .\"
2 .\" Copyright (c) 2008-2009 Robert N. M. Watson
3 .\" All rights reserved.
4 .\"
5 .\" This software was developed at the University of Cambridge Computer
6 .\" Laboratory with support from a grant from Google, Inc.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" SUCH DAMAGE.
28 .\"
29 .\" $FreeBSD$
30 .\"
31 .Dd February 25, 2012
32 .Dt CAP_ENTER 2
33 .Os
34 .Sh NAME
35 .Nm cap_enter ,
36 .Nm cap_getmode
37 .Nd Capability mode system calls
38 .Sh LIBRARY
39 .Lb libc
40 .Sh SYNOPSIS
41 .In sys/capability.h
42 .Ft int
43 .Fn cap_enter "void"
44 .Ft int
45 .Fn cap_getmode "u_int *modep"
46 .Sh DESCRIPTION
47 .Fn cap_enter
48 places the current process into capability mode, a mode of execution in which
49 processes may only issue system calls operating on file descriptors or
50 reading limited global system state.
51 Access to global name spaces, such as file system or IPC name spaces, is
52 prevented.
53 If the process is already in a capability mode sandbox, the system call is a
54 no-op.
55 Future process descendants create with
56 .Xr fork 2
57 or
58 .Xr pdfork 2
59 will be placed in capability mode from inception.
60 .Pp
61 When combined with capabilities created with
62 .Xr cap_new 2 ,
63 .Fn cap_enter
64 may be used to create kernel-enforced sandboxes in which
65 appropriately-crafted applications or application components may be run.
66 .Pp
67 .Fn cap_getmode
68 returns a flag indicating whether or not the process is in a capability mode
69 sandbox.
70 .Sh CAVEAT
71 Creating effective process sandboxes is a tricky process that involves
72 identifying the least possible rights required by the process and then
73 passing those rights into the process in a safe manner.
74 See the CAVEAT
75 section of
76 .Xr cap_new 2
77 for why this is particularly tricky with UNIX file descriptors as the
78 canonical representation of a right.
79 Consumers of
80 .Fn cap_enter
81 should also be aware of other inherited rights, such as access to VM
82 resources, memory contents, and other process properties that should be
83 considered.
84 It is advisable to use
85 .Xr fexecve 2
86 to create a runtime environment inside the sandbox that has as few implicitly
87 acquired rights as possible.
88 .Sh RETURN VALUES
89 .Rv -std cap_enter cap_getmode
90 .Sh SEE ALSO
91 .Xr cap_new 2 ,
92 .Xr fexecve 2 ,
93 .Xr capsicum 4
94 .Sh HISTORY
95 Support for capabilities and capabilities mode was developed as part of the
96 .Tn TrustedBSD
97 Project.
98 .Sh AUTHORS
99 These functions and the capability facility were created by
100 .An "Robert N. M. Watson"
101 at the University of Cambridge Computer Laboratory with support from a grant
102 from Google, Inc.