blob: ce8e67c3059fb349f4c00f1eba0e95fc86e07f68 [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
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -04006[\fIOPTION\fR]... <\fIPROGRAM\fR> [\fIargs\fR]...
Elly Jonescd7a9042011-07-22 13:56:51 -04007.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
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040013and architectures that support the \fBPR_ALT_SYSCALL\fR option of \fBprctl\fR(2).
Andrew Brestickereac28942015-11-11 16:04:46 -080014.TP
Mike Frysinger8f0665b2018-01-17 14:26:09 -050015\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.
Mike Frysingereaab4202017-08-14 14:57:21 -040017The \fIsrc\fR path must be an absolute path.
Mike Frysinger8f0665b2018-01-17 14:26:09 -050018If \fIdest\fR is not specified, it will default to \fIsrc\fR.
Mike Frysingereaab4202017-08-14 14:57:21 -040019If the destination does not exist, it will be created as a file or directory
Mike Frysinger5fdba4e2018-01-17 15:39:48 -050020based on the \fIsrc\fR type (including missing parent directories).
Elly Jones51a5b6c2011-10-12 19:09:26 -040021.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040022\fB-c <caps>\fR
23Restrict capabilities to \fIcaps\fR. When used in conjunction with \fB-u\fR and
24\fB-g\fR, this allows a program to have access to only certain parts of root's
25default privileges while running as another user and group ID altogether. Note
26that these capabilities are not inherited by subprocesses of the process given
27capabilities unless those subprocesses have POSIX file capabilities. See
28\fBcapabilities\fR(7).
29.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080030\fB-C <dir>\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040031Change root (using \fBchroot\fR(2)) to \fIdir\fR.
Dylan Reid6cae0b22015-11-18 18:47:49 -080032.TP
Mike Frysinger33ffef32017-01-13 19:53:19 -050033\fB-d\fR, \fB--mount-dev\fR
34Create a new /dev mount with a minimal set of nodes. Implies \fB-v\fR.
35Additional nodes can be bound with the \fB-b\fR or \fB-k\fR options.
36The initial set of nodes are: full null tty urandom zero.
37Symlinks are also created for: fd ptmx stderr stdin stdout.
38.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080039\fB-e[file]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080040Enter a new network namespace, or if \fIfile\fR is specified, enter an existing
Dylan Reid6cae0b22015-11-18 18:47:49 -080041network namespace specified by \fIfile\fR which is typically of the form
42/proc/<pid>/ns/net.
43.TP
44\fB-f <file>\fR
45Write the pid of the jailed process to \fIfile\fR.
46.TP
Lutz Justen13807cb2017-01-03 17:11:55 +010047\fB-g <group>\fR
48Change groups to \fIgroup\fR, which may be either a group name or a numeric
49group ID.
50.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040051\fB-G\fR
52Inherit all the supplementary groups of the user specified with \fB-u\fR. It
53is an error to use this option without having specified a \fBuser name\fR to
54\fB-u\fR.
55.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040056\fB-h\fR
57Print a help message.
58.TP
Will Drewry32ac9f52011-08-18 21:36:27 -050059\fB-H\fR
60Print a help message detailing supported system call names for seccomp_filter.
61(Other direct numbers may be specified if minijail0 is not in sync with the
Mike Frysinger4a5fed62018-01-17 16:04:50 -050062host kernel or something like 32/64-bit compatibility issues exist.)
Will Drewry32ac9f52011-08-18 21:36:27 -050063.TP
Brian Norris3b5841b2016-03-16 16:43:49 -070064\fB-I\fR
65Run \fIprogram\fR as init (pid 1) inside a new pid namespace (implies \fB-p\fR).
66.TP
Mike Frysingerfea05c62018-01-17 16:56:48 -050067\fB-k <src>,<dest>,<type>[,<flags>[,<data>]]\fR
Mike Frysinger4f3e09f2018-01-24 18:01:16 -050068Mount \fIsrc\fR, a \fItype\fR filesystem, at \fIdest\fR. If a chroot or pivot
69root is active, \fIdest\fR will automatically be placed below that path.
70
71The \fIflags\fR field is optional and is a hex constant. These represent the
72\fIMS_XXX\fR settings (see \fBmount\fR(2) for details). Their values can be
73looked up in the sys/mount.h header file. \fI0xe\fR is a common value here
74(a writable mount with nodev/nosuid/noexec bits set), and it is strongly
75recommended that all mounts have these three bits set whenever possible.
76
77The \fIdata\fR field is optional and is a comma delimited string (see
78\fBmount\fR(2) for details). It is passed directly to the kernel, so all
79fields here are filesystem specific.
80
Mike Frysingereaab4202017-08-14 14:57:21 -040081If the mount is not a pseudo filesystem (e.g. proc or sysfs), \fIsrc\fR path
82must be an absolute path (e.g. \fI/dev/sda1\fR and not \fIsda1\fR).
Mike Frysinger4f3e09f2018-01-24 18:01:16 -050083
Mike Frysinger5fdba4e2018-01-17 15:39:48 -050084If the destination does not exist, it will be created as a directory (including
85missing parent directories).
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080086.TP
Mike Frysinger785b1c32018-02-23 15:47:24 -050087\fB-K[mode]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080088Don't mark all existing mounts as MS_PRIVATE.
89This option is \fBdangerous\fR as it negates most of the functionality of \fB-v\fR.
90You very likely don't need this.
Mike Frysinger785b1c32018-02-23 15:47:24 -050091
92You may specify a mount propagation mode in which case, that will be used
93instead of the default MS_PRIVATE. See the \fBmount\fR(2) man page and the
94kernel docs \fIDocumentation/filesystems/sharedsubtree.txt\fR for more
95technical details, but a brief guide:
96
97.IP
98\[bu] \fBslave\fR Changes in the parent mount namespace will propagate in, but
99changes in this mount namespace will not propagate back out. This is usually
100what people want to use.
101.IP
102\[bu] \fBprivate\fR No changes in either mount namespace will propagate.
103This is the default behavior if you don't specify \fB-K\fR.
104.IP
105\[bu] \fBshared\fR Changes in the parent and this mount namespace will freely
106propagate back and forth. This is not recommended.
107.IP
108\[bu] \fBunbindable\fR Mark all mounts as unbindable.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800109.TP
Dylan Reidf7942472015-11-18 17:55:26 -0800110\fB-l\fR
111Run inside a new IPC namespace. This option makes the program's System V IPC
112namespace independent.
113.TP
Brian Norris3b5841b2016-03-16 16:43:49 -0700114\fB-L\fR
115Report blocked syscalls to syslog when using seccomp filter. This option will
116force certain syscalls to be allowed in order to achieve this, depending on the
117system.
118.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500119\fB-m[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800120Set the uid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400121\fBnewuidmap\fR(1). Multiple mappings should be separated by ','. With no mapping,
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500122map the current uid to root inside the user namespace.
Dylan Reid6cae0b22015-11-18 18:47:49 -0800123.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500124\fB-M[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800125Set the gid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400126\fBnewgidmap\fR(1). Multiple mappings should be separated by ','. With no mapping,
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500127map the current gid to root inside the user namespace.
Dylan Reid6cae0b22015-11-18 18:47:49 -0800128.TP
Brian Norris3b5841b2016-03-16 16:43:49 -0700129\fB-n\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400130Set the process's \fIno_new_privs\fR bit. See \fBprctl\fR(2) and the kernel
Brian Norris3b5841b2016-03-16 16:43:49 -0700131source file \fIDocumentation/prctl/no_new_privs.txt\fR for more info.
132.TP
Dylan Reid87e58512016-07-11 14:35:12 -0700133\fB-N\fR
134Run inside a new cgroup namespace. This option runs the program with a cgroup
135view showing the program's cgroup as the root. This is only available on v4.6+
136of the Linux kernel.
137.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400138\fB-p\fR
139Run inside a new PID namespace. This option will make it impossible for the
Elly Jonese58176c2012-01-23 11:46:17 -0500140program to see or affect processes that are not its descendants. This implies
141\fB-v\fR and \fB-r\fR, since otherwise the process can see outside its namespace
142by inspecting /proc.
Elly Jonescd7a9042011-07-22 13:56:51 -0400143.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -0800144\fB-P <dir>\fR
145Set \fIdir\fR as the root fs using \fBpivot_root\fR. Implies \fB-v\fR, not
146compatible with \fB-C\fR.
147.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400148\fB-r\fR
Dylan Reid6cae0b22015-11-18 18:47:49 -0800149Remount /proc readonly. This implies \fB-v\fR. Remounting /proc readonly means
150that even if the process has write access to a system config knob in /proc
151(e.g., in /sys/kernel), it cannot change the value.
Elly Jonescd7a9042011-07-22 13:56:51 -0400152.TP
Luis Hector Chavez7058a2d2018-01-29 08:41:34 -0800153\fB-R <rlim_type>,<rlim_cur>,<rlim_max>\fR
154Set an rlimit value, see \fBgetrlimit\fR(2) for allowed values. The string
155\fBunlimited\fR can be used for \fBrlim_cur\fR and \fBrlim_max\fR, which will
156translate to \fBRLIM_INFINITY\fR.
Dylan Reid0f72ef42017-06-06 15:42:49 -0700157.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400158\fB-s\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400159Enable \fBseccomp\fR(2) in mode 1, which restricts the child process to a very
160small set of system calls.
Mike Frysingere61fd662017-06-20 14:07:41 -0400161You most likely do not want to use this with the seccomp filter mode (\fB-S\fR)
162as they are completely different (even though they have similar names).
Will Drewry32ac9f52011-08-18 21:36:27 -0500163.TP
164\fB-S <arch-specific seccomp_filter policy file>\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400165Enable \fBseccomp\fR(2) in mode 13 which restricts the child process to a set of
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800166system calls defined in the policy file. Note that system calls often change
Will Drewry32ac9f52011-08-18 21:36:27 -0500167names based on the architecture or mode. (uname -m is your friend.)
Elly Jonescd7a9042011-07-22 13:56:51 -0400168.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500169\fB-t[size]\fR
Mike Frysingerec7def22017-01-13 18:44:45 -0500170Mounts a tmpfs filesystem on /tmp. /tmp must exist already (e.g. in the chroot).
Martin Pelikánab9eb442017-01-25 11:53:58 +1100171The filesystem has a default size of "64M", overridden with an optional
172argument. It has standard /tmp permissions (1777), and is mounted
173nodev/noexec/nosuid. Implies \fB-v\fR.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800174.TP
Matthew Dempsky2ed09122016-02-11 09:43:37 -0800175\fB-T <type>\fR
Graziano Misuraca58602a82017-08-28 17:33:15 -0700176Assume binary's ELF linkage type is \fItype\fR, which must be either 'static'
177or 'dynamic'. Either setting will prevent minijail0 from manually parsing the
178ELF header to determine the type. Type 'static' can be used to avoid preload
179hooking, and will force minijail0 to instead set everything up before the
180program is executed. Type 'dynamic' will force minijail0 to preload
181\fIlibminijailpreload.so\fR to setup hooks, but will fail on actually
182statically-linked binaries.
Matthew Dempsky2ed09122016-02-11 09:43:37 -0800183.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400184\fB-u <user>\fR
185Change users to \fIuser\fR, which may be either a user name or a numeric user
186ID.
187.TP
Brian Norris3b5841b2016-03-16 16:43:49 -0700188\fB-U\fR
189Enter a new user namespace (implies \fB-p\fR).
190.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400191\fB-v\fR
192Run inside a new VFS namespace. This option makes the program's mountpoints
193independent of the rest of the system's.
Dylan Reid6cae0b22015-11-18 18:47:49 -0800194.TP
195\fB-V <file>\fR
196Enter the VFS namespace specified by \fIfile\fR.
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400197.TP
Chirantan Ekbote866bb3a2017-02-07 12:26:42 -0800198\fB-w\fR
199Create and join a new anonymous session keyring. See \fBkeyrings\fR(7) for more
200details.
201.TP
Lutz Justen13807cb2017-01-03 17:11:55 +0100202\fB-y\fR
203Keep the current user's supplementary groups.
204.TP
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400205\fB-Y\fR
206Synchronize seccomp filters across thread group.
Mike Frysingerb9a7b162017-05-30 15:25:49 -0400207.TP
208\fB--uts[=hostname]\fR
209Create a new UTS/hostname namespace, and optionally set the hostname in the new
210namespace to \fIhostname\fR.
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700211.TP
212\fB--logging=<system>\fR
213Use \fIsystem\fR as the logging system. \fIsystem\fR must be one of
214\fBsyslog\fR (the default) or \fBstderr\fR.
Luis Hector Chavezd45fc422017-10-25 15:11:53 -0700215.TP
216\fB--profile <profile>\fR
217Choose from one of the available sandboxing profiles, which are simple way to
218get a standardized environment. See the
219.BR "SANDBOXING PROFILES"
220section below for the full list of supported values for \fIprofile\fR.
221.SH SANDBOXING PROFILES
222The following sandboxing profiles are supported:
223.TP
224\fBminimalistic-mountns\fR
225Set up a minimalistic mount namespace. Equivalent to \fB-v -P /var/empty
226-b /,/ -b /proc,/proc -t -r --mount-dev\fR.
Elly Jonescd7a9042011-07-22 13:56:51 -0400227.SH IMPLEMENTATION
228This program is broken up into two parts: \fBminijail0\fR (the frontend) and a helper
229library called \fBlibminijailpreload\fR. Some jailings can only be achieved from
230the process to which they will actually apply - specifically capability use
231(since capabilities are not inherited to an exec'd process unless the exec'd
232process has POSIX file capabilities), seccomp (since we can't exec() once we're
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800233seccomp'd), and ptrace-disable (which is always cleared on exec()).
Elly Jonescd7a9042011-07-22 13:56:51 -0400234
235To this end, \fBlibminijailpreload\fR is forcibly loaded into all
236dynamically-linked target programs if any of these restrictions are in effect;
237we pass the specific restrictions in an environment variable which the preloaded
238library looks for. The forcibly-loaded library then applies the restrictions
239to the newly-loaded program.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800240
Elly Jonescd7a9042011-07-22 13:56:51 -0400241.SH AUTHOR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800242The Chromium OS Authors <chromiumos-dev@chromium.org>
Elly Jonescd7a9042011-07-22 13:56:51 -0400243.SH COPYRIGHT
244Copyright \(co 2011 The Chromium OS Authors
245License BSD-like.
246.SH "SEE ALSO"
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400247\fBlibminijail.h\fR \fBminijail0\fR(5)