blob: de3c61fe68be538fa9ce1383a368ac0f3c89e51b [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
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.
Mike Frysingereaab4202017-08-14 14:57:21 -040017The \fIsrc\fR path must be an absolute path.
18If the destination does not exist, it will be created as a file or directory
19based on the \fIsrc\fR type.
Elly Jones51a5b6c2011-10-12 19:09:26 -040020.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040021\fB-c <caps>\fR
22Restrict capabilities to \fIcaps\fR. When used in conjunction with \fB-u\fR and
23\fB-g\fR, this allows a program to have access to only certain parts of root's
24default privileges while running as another user and group ID altogether. Note
25that these capabilities are not inherited by subprocesses of the process given
26capabilities unless those subprocesses have POSIX file capabilities. See
27\fBcapabilities\fR(7).
28.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -080029\fB-C <dir>\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040030Change root (using \fBchroot\fR(2)) to \fIdir\fR.
Dylan Reid6cae0b22015-11-18 18:47:49 -080031.TP
32\fB-e[file]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080033Enter a new network namespace, or if \fIfile\fR is specified, enter an existing
Dylan Reid6cae0b22015-11-18 18:47:49 -080034network namespace specified by \fIfile\fR which is typically of the form
35/proc/<pid>/ns/net.
36.TP
37\fB-f <file>\fR
38Write the pid of the jailed process to \fIfile\fR.
39.TP
Lutz Justen13807cb2017-01-03 17:11:55 +010040\fB-g <group>\fR
41Change groups to \fIgroup\fR, which may be either a group name or a numeric
42group ID.
43.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040044\fB-G\fR
45Inherit all the supplementary groups of the user specified with \fB-u\fR. It
46is an error to use this option without having specified a \fBuser name\fR to
47\fB-u\fR.
48.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040049\fB-h\fR
50Print a help message.
51.TP
Will Drewry32ac9f52011-08-18 21:36:27 -050052\fB-H\fR
53Print a help message detailing supported system call names for seccomp_filter.
54(Other direct numbers may be specified if minijail0 is not in sync with the
55 host kernel or something like 32/64-bit compatibility issues exist.)
56.TP
Brian Norris3b5841b2016-03-16 16:43:49 -070057\fB-I\fR
58Run \fIprogram\fR as init (pid 1) inside a new pid namespace (implies \fB-p\fR).
59.TP
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080060\fB-k <src>,<dest>,<type>[,<flags>]\fR
61Mount \fIsrc\fR, a \fItype\fR filesystem, into the chroot directory at \fIdest\fR, with optional \fIflags\fR.
Mike Frysingereaab4202017-08-14 14:57:21 -040062If the mount is not a pseudo filesystem (e.g. proc or sysfs), \fIsrc\fR path
63must be an absolute path (e.g. \fI/dev/sda1\fR and not \fIsda1\fR).
64If the destination does not exist, it will be created as a directory.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080065.TP
66\fB-K\fR
67Don't mark all existing mounts as MS_PRIVATE.
68This option is \fBdangerous\fR as it negates most of the functionality of \fB-v\fR.
69You very likely don't need this.
70.TP
Dylan Reidf7942472015-11-18 17:55:26 -080071\fB-l\fR
72Run inside a new IPC namespace. This option makes the program's System V IPC
73namespace independent.
74.TP
Brian Norris3b5841b2016-03-16 16:43:49 -070075\fB-L\fR
76Report blocked syscalls to syslog when using seccomp filter. This option will
77force certain syscalls to be allowed in order to achieve this, depending on the
78system.
79.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -050080\fB-m[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080081Set the uid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040082\fBnewuidmap\fR(1). Multiple mappings should be separated by ','. With no mapping,
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -050083map the current uid to root inside the user namespace.
Dylan Reid6cae0b22015-11-18 18:47:49 -080084.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -050085\fB-M[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -080086Set the gid mapping of a user namespace (implies \fB-pU\fR). Same arguments as
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040087\fBnewgidmap\fR(1). Multiple mappings should be separated by ','. With no mapping,
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -050088map the current gid to root inside the user namespace.
Dylan Reid6cae0b22015-11-18 18:47:49 -080089.TP
Brian Norris3b5841b2016-03-16 16:43:49 -070090\fB-n\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -040091Set the process's \fIno_new_privs\fR bit. See \fBprctl\fR(2) and the kernel
Brian Norris3b5841b2016-03-16 16:43:49 -070092source file \fIDocumentation/prctl/no_new_privs.txt\fR for more info.
93.TP
Dylan Reid87e58512016-07-11 14:35:12 -070094\fB-N\fR
95Run inside a new cgroup namespace. This option runs the program with a cgroup
96view showing the program's cgroup as the root. This is only available on v4.6+
97of the Linux kernel.
98.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040099\fB-p\fR
100Run inside a new PID namespace. This option will make it impossible for the
Elly Jonese58176c2012-01-23 11:46:17 -0500101program to see or affect processes that are not its descendants. This implies
102\fB-v\fR and \fB-r\fR, since otherwise the process can see outside its namespace
103by inspecting /proc.
Elly Jonescd7a9042011-07-22 13:56:51 -0400104.TP
Dylan Reid6cae0b22015-11-18 18:47:49 -0800105\fB-P <dir>\fR
106Set \fIdir\fR as the root fs using \fBpivot_root\fR. Implies \fB-v\fR, not
107compatible with \fB-C\fR.
108.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400109\fB-r\fR
Dylan Reid6cae0b22015-11-18 18:47:49 -0800110Remount /proc readonly. This implies \fB-v\fR. Remounting /proc readonly means
111that even if the process has write access to a system config knob in /proc
112(e.g., in /sys/kernel), it cannot change the value.
Elly Jonescd7a9042011-07-22 13:56:51 -0400113.TP
Dylan Reid0f72ef42017-06-06 15:42:49 -0700114\fB-R <rlim_type, rlim_cur, rlim_max>\fR
115Set an rlimit value, see \fBgetrlimit\fR(2) for allowed values.
116.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400117\fB-s\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400118Enable \fBseccomp\fR(2) in mode 1, which restricts the child process to a very
119small set of system calls.
Mike Frysingere61fd662017-06-20 14:07:41 -0400120You most likely do not want to use this with the seccomp filter mode (\fB-S\fR)
121as they are completely different (even though they have similar names).
Will Drewry32ac9f52011-08-18 21:36:27 -0500122.TP
123\fB-S <arch-specific seccomp_filter policy file>\fR
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400124Enable \fBseccomp\fR(2) in mode 13 which restricts the child process to a set of
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800125system calls defined in the policy file. Note that system calls often change
Will Drewry32ac9f52011-08-18 21:36:27 -0500126names based on the architecture or mode. (uname -m is your friend.)
Elly Jonescd7a9042011-07-22 13:56:51 -0400127.TP
Jorge Lucangeli Obes959f6562017-02-07 11:03:46 -0500128\fB-t[size]\fR
Mike Frysingerec7def22017-01-13 18:44:45 -0500129Mounts a tmpfs filesystem on /tmp. /tmp must exist already (e.g. in the chroot).
Martin Pelikánab9eb442017-01-25 11:53:58 +1100130The filesystem has a default size of "64M", overridden with an optional
131argument. It has standard /tmp permissions (1777), and is mounted
132nodev/noexec/nosuid. Implies \fB-v\fR.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800133.TP
Matthew Dempsky2ed09122016-02-11 09:43:37 -0800134\fB-T <type>\fR
135Assume program's ELF linkage type is \fItype\fR,
136which should be either 'static' or 'dynamic'.
137.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400138\fB-u <user>\fR
139Change users to \fIuser\fR, which may be either a user name or a numeric user
140ID.
141.TP
Brian Norris3b5841b2016-03-16 16:43:49 -0700142\fB-U\fR
143Enter a new user namespace (implies \fB-p\fR).
144.TP
Elly Jonescd7a9042011-07-22 13:56:51 -0400145\fB-v\fR
146Run inside a new VFS namespace. This option makes the program's mountpoints
147independent of the rest of the system's.
Dylan Reid6cae0b22015-11-18 18:47:49 -0800148.TP
149\fB-V <file>\fR
150Enter the VFS namespace specified by \fIfile\fR.
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400151.TP
Chirantan Ekbote866bb3a2017-02-07 12:26:42 -0800152\fB-w\fR
153Create and join a new anonymous session keyring. See \fBkeyrings\fR(7) for more
154details.
155.TP
Lutz Justen13807cb2017-01-03 17:11:55 +0100156\fB-y\fR
157Keep the current user's supplementary groups.
158.TP
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400159\fB-Y\fR
160Synchronize seccomp filters across thread group.
Mike Frysingerb9a7b162017-05-30 15:25:49 -0400161.TP
162\fB--uts[=hostname]\fR
163Create a new UTS/hostname namespace, and optionally set the hostname in the new
164namespace to \fIhostname\fR.
Elly Jonescd7a9042011-07-22 13:56:51 -0400165.SH IMPLEMENTATION
166This program is broken up into two parts: \fBminijail0\fR (the frontend) and a helper
167library called \fBlibminijailpreload\fR. Some jailings can only be achieved from
168the process to which they will actually apply - specifically capability use
169(since capabilities are not inherited to an exec'd process unless the exec'd
170process has POSIX file capabilities), seccomp (since we can't exec() once we're
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800171seccomp'd), and ptrace-disable (which is always cleared on exec()).
Elly Jonescd7a9042011-07-22 13:56:51 -0400172
173To this end, \fBlibminijailpreload\fR is forcibly loaded into all
174dynamically-linked target programs if any of these restrictions are in effect;
175we pass the specific restrictions in an environment variable which the preloaded
176library looks for. The forcibly-loaded library then applies the restrictions
177to the newly-loaded program.
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800178
Elly Jonescd7a9042011-07-22 13:56:51 -0400179.SH AUTHOR
Jorge Lucangeli Obesa521bee2016-03-03 13:47:57 -0800180The Chromium OS Authors <chromiumos-dev@chromium.org>
Elly Jonescd7a9042011-07-22 13:56:51 -0400181.SH COPYRIGHT
182Copyright \(co 2011 The Chromium OS Authors
183License BSD-like.
184.SH "SEE ALSO"
Mike Frysinger0fe4e4f2017-06-20 14:01:09 -0400185\fBlibminijail.h\fR \fBminijail0\fR(5)