blob: 8d7e188f5f763a9fda4259fec4340f9d32121db1 [file] [log] [blame]
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -08001.TH MINIJAIL0 "1" "March 2016" "Chromium OS" "User Commands"
Elly Jonescd7a9042011-07-22 13:56:51 -04002.SH NAME
3minijail0 \- sandbox a process
4.SH SYNOPSIS
5.B minijail0
6[\fIOPTION\fR]... <\fIprogram\fR> [\fIargs\fR]...
7.SH DESCRIPTION
8.PP
9Runs PROGRAM inside a sandbox.
10.TP
Andrew Brestickereac28942015-11-11 16:04:46 -080011\fB-a <table>\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080012Run using the alternate syscall table named \fItable\fR. Only available on kernels
Andrew Brestickereac28942015-11-11 16:04:46 -080013and architectures that support the PR_ALT_SYSCALL option of prctl(2).
14.TP
Elly Jones51a5b6c2011-10-12 19:09:26 -040015\fB-b <src>,<dest>[,<writeable>]
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080016Bind-mount \fIsrc\fR into the chroot directory at \fIdest\fR, optionally writeable.
Elly Jones51a5b6c2011-10-12 19:09:26 -040017.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040018\fB-c <caps>\fR
19Restrict capabilities to \fIcaps\fR. When used in conjunction with \fB-u\fR and
20\fB-g\fR, this allows a program to have access to only certain parts of root's
21default privileges while running as another user and group ID altogether. Note
22that these capabilities are not inherited by subprocesses of the process given
23capabilities unless those subprocesses have POSIX file capabilities. See
24\fBcapabilities\fR(7).
25.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080026\fB-C <dir>\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080027Change root (using chroot(2)) to \fIdir\fR.
Dylan Reid6cae0b22015-11-18 18:47:49 -080028.TP
29\fB-e[file]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080030Enter a new network namespace, or if \fIfile\fR is specified, enter an existing
Dylan Reid6cae0b22015-11-18 18:47:49 -080031network namespace specified by \fIfile\fR which is typically of the form
32/proc/<pid>/ns/net.
33.TP
34\fB-f <file>\fR
35Write the pid of the jailed process to \fIfile\fR.
36.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040037\fB-G\fR
38Inherit all the supplementary groups of the user specified with \fB-u\fR. It
39is an error to use this option without having specified a \fBuser name\fR to
40\fB-u\fR.
41.TP
42\fB-g <group>\fR
43Change groups to \fIgroup\fR, which may be either a group name or a numeric
44group ID.
45.TP
46\fB-h\fR
47Print a help message.
48.TP
Will Drewry32ac9f52011-08-18 21:36:27 -050049\fB-H\fR
50Print a help message detailing supported system call names for seccomp_filter.
51(Other direct numbers may be specified if minijail0 is not in sync with the
52 host kernel or something like 32/64-bit compatibility issues exist.)
53.TP
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080054\fB-k <src>,<dest>,<type>[,<flags>]\fR
55Mount \fIsrc\fR, a \fItype\fR filesystem, into the chroot directory at \fIdest\fR, with optional \fIflags\fR.
56.TP
57\fB-K\fR
58Don't mark all existing mounts as MS_PRIVATE.
59This option is \fBdangerous\fR as it negates most of the functionality of \fB-v\fR.
60You very likely don't need this.
61.TP
Dylan Reidf7942472015-11-18 17:55:26 -080062\fB-l\fR
63Run inside a new IPC namespace. This option makes the program's System V IPC
64namespace independent.
65.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080066\fB-m "<uid> <loweruid> <count>[,<uid> <loweruid> <count>]"\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080067Set the uid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
68\fBnewuidmap(1)\fR. Multiple mappings should be separated by ','.
Dylan Reid6cae0b22015-11-18 18:47:49 -080069.TP
70\fB-M "<uid> <loweruid> <count>[,<uid> <loweruid> <count>]"\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080071Set the gid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
72\fBnewgidmap(1)\fR. Multiple mappings should be separated by ','.
Dylan Reid6cae0b22015-11-18 18:47:49 -080073.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040074\fB-p\fR
75Run inside a new PID namespace. This option will make it impossible for the
Elly Jonese58176c2012-01-23 11:46:17 -050076program to see or affect processes that are not its descendants. This implies
77\fB-v\fR and \fB-r\fR, since otherwise the process can see outside its namespace
78by inspecting /proc.
Elly Jonescd7a9042011-07-22 13:56:51 -040079.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080080\fB-P <dir>\fR
81Set \fIdir\fR as the root fs using \fBpivot_root\fR. Implies \fB-v\fR, not
82compatible with \fB-C\fR.
83.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040084\fB-r\fR
Dylan Reid6cae0b22015-11-18 18:47:49 -080085Remount /proc readonly. This implies \fB-v\fR. Remounting /proc readonly means
86that even if the process has write access to a system config knob in /proc
87(e.g., in /sys/kernel), it cannot change the value.
Elly Jonescd7a9042011-07-22 13:56:51 -040088.TP
89\fB-s\fR
90Enable seccomp(2) in mode 1, which restricts the child process to a very small
Will Drewry32ac9f52011-08-18 21:36:27 -050091set of system calls.
92.TP
93\fB-S <arch-specific seccomp_filter policy file>\fR
94Enable seccomp(2) in mode 13 which restricts the child process to a set of
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080095system calls defined in the policy file. Note that system calls often change
Will Drewry32ac9f52011-08-18 21:36:27 -050096names based on the architecture or mode. (uname -m is your friend.)
Elly Jonescd7a9042011-07-22 13:56:51 -040097.TP
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080098\fB-t\fR
99Mounts a tmpfs filesystem on /tmp. /tmp must exist in the chroot.
100This must be used with \fB-C\fR. The default filesystem has a max size of 128M
101and has standard /tmp permissions (777).
102.TP
Matthew Dempsky2ed09122016-02-11 09:43:37 -0800103\fB-T <type>\fR
104Assume program's ELF linkage type is \fItype\fR,
105which should be either 'static' or 'dynamic'.
106.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400107\fB-u <user>\fR
108Change users to \fIuser\fR, which may be either a user name or a numeric user
109ID.
110.TP
111\fB-v\fR
112Run inside a new VFS namespace. This option makes the program's mountpoints
113independent of the rest of the system's.
Dylan Reid6cae0b22015-11-18 18:47:49 -0800114.TP
115\fB-V <file>\fR
116Enter the VFS namespace specified by \fIfile\fR.
Elly Jonescd7a9042011-07-22 13:56:51 -0400117.SH IMPLEMENTATION
118This program is broken up into two parts: \fBminijail0\fR (the frontend) and a helper
119library called \fBlibminijailpreload\fR. Some jailings can only be achieved from
120the process to which they will actually apply - specifically capability use
121(since capabilities are not inherited to an exec'd process unless the exec'd
122process has POSIX file capabilities), seccomp (since we can't exec() once we're
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800123seccomp'd), and ptrace-disable (which is always cleared on exec()).
Elly Jonescd7a9042011-07-22 13:56:51 -0400124
125To this end, \fBlibminijailpreload\fR is forcibly loaded into all
126dynamically-linked target programs if any of these restrictions are in effect;
127we pass the specific restrictions in an environment variable which the preloaded
128library looks for. The forcibly-loaded library then applies the restrictions
129to the newly-loaded program.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800130
Elly Jonescd7a9042011-07-22 13:56:51 -0400131.SH AUTHOR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800132The Chromium OS Authors <chromiumos-dev@chromium.org>
Elly Jonescd7a9042011-07-22 13:56:51 -0400133.SH COPYRIGHT
134Copyright \(co 2011 The Chromium OS Authors
135License BSD-like.
136.SH "SEE ALSO"
Will Drewry32ac9f52011-08-18 21:36:27 -0500137\fBlibminijail.h\fR \fBminijail0(5)\fR