Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 1 | .TH MINIJAIL0 "1" "March 2016" "Chromium OS" "User Commands" |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 2 | .SH NAME |
| 3 | minijail0 \- sandbox a process |
| 4 | .SH SYNOPSIS |
| 5 | .B minijail0 |
Jorge Lucangeli Obes | 1365061 | 2016-09-02 11:27:29 -0400 | [diff] [blame] | 6 | [\fIOPTION\fR]... <\fIPROGRAM\fR> [\fIargs\fR]... |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 7 | .SH DESCRIPTION |
| 8 | .PP |
| 9 | Runs PROGRAM inside a sandbox. |
| 10 | .TP |
Andrew Bresticker | eac2894 | 2015-11-11 16:04:46 -0800 | [diff] [blame] | 11 | \fB-a <table>\fR |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 12 | Run using the alternate syscall table named \fItable\fR. Only available on kernels |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 13 | and architectures that support the \fBPR_ALT_SYSCALL\fR option of \fBprctl\fR(2). |
Andrew Bresticker | eac2894 | 2015-11-11 16:04:46 -0800 | [diff] [blame] | 14 | .TP |
Elly Jones | 51a5b6c | 2011-10-12 19:09:26 -0400 | [diff] [blame] | 15 | \fB-b <src>,<dest>[,<writeable>] |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 16 | Bind-mount \fIsrc\fR into the chroot directory at \fIdest\fR, optionally writeable. |
Elly Jones | 51a5b6c | 2011-10-12 19:09:26 -0400 | [diff] [blame] | 17 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 18 | \fB-c <caps>\fR |
| 19 | Restrict 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 |
| 21 | default privileges while running as another user and group ID altogether. Note |
| 22 | that these capabilities are not inherited by subprocesses of the process given |
| 23 | capabilities unless those subprocesses have POSIX file capabilities. See |
| 24 | \fBcapabilities\fR(7). |
| 25 | .TP |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 26 | \fB-C <dir>\fR |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 27 | Change root (using \fBchroot\fR(2)) to \fIdir\fR. |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 28 | .TP |
| 29 | \fB-e[file]\fR |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 30 | Enter a new network namespace, or if \fIfile\fR is specified, enter an existing |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 31 | network namespace specified by \fIfile\fR which is typically of the form |
| 32 | /proc/<pid>/ns/net. |
| 33 | .TP |
| 34 | \fB-f <file>\fR |
| 35 | Write the pid of the jailed process to \fIfile\fR. |
| 36 | .TP |
Lutz Justen | 13807cb | 2017-01-03 17:11:55 +0100 | [diff] [blame] | 37 | \fB-g <group>\fR |
| 38 | Change groups to \fIgroup\fR, which may be either a group name or a numeric |
| 39 | group ID. |
| 40 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 41 | \fB-G\fR |
| 42 | Inherit all the supplementary groups of the user specified with \fB-u\fR. It |
| 43 | is an error to use this option without having specified a \fBuser name\fR to |
| 44 | \fB-u\fR. |
| 45 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 46 | \fB-h\fR |
| 47 | Print a help message. |
| 48 | .TP |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 49 | \fB-H\fR |
| 50 | Print 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 |
Brian Norris | 3b5841b | 2016-03-16 16:43:49 -0700 | [diff] [blame] | 54 | \fB-I\fR |
| 55 | Run \fIprogram\fR as init (pid 1) inside a new pid namespace (implies \fB-p\fR). |
| 56 | .TP |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 57 | \fB-k <src>,<dest>,<type>[,<flags>]\fR |
| 58 | Mount \fIsrc\fR, a \fItype\fR filesystem, into the chroot directory at \fIdest\fR, with optional \fIflags\fR. |
| 59 | .TP |
| 60 | \fB-K\fR |
| 61 | Don't mark all existing mounts as MS_PRIVATE. |
| 62 | This option is \fBdangerous\fR as it negates most of the functionality of \fB-v\fR. |
| 63 | You very likely don't need this. |
| 64 | .TP |
Dylan Reid | f794247 | 2015-11-18 17:55:26 -0800 | [diff] [blame] | 65 | \fB-l\fR |
| 66 | Run inside a new IPC namespace. This option makes the program's System V IPC |
| 67 | namespace independent. |
| 68 | .TP |
Brian Norris | 3b5841b | 2016-03-16 16:43:49 -0700 | [diff] [blame] | 69 | \fB-L\fR |
| 70 | Report blocked syscalls to syslog when using seccomp filter. This option will |
| 71 | force certain syscalls to be allowed in order to achieve this, depending on the |
| 72 | system. |
| 73 | .TP |
Jorge Lucangeli Obes | 959f656 | 2017-02-07 11:03:46 -0500 | [diff] [blame] | 74 | \fB-m[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 75 | Set the uid mapping of a user namespace (implies \fB-pU\fR). Same arguments as |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 76 | \fBnewuidmap\fR(1). Multiple mappings should be separated by ','. With no mapping, |
Jorge Lucangeli Obes | 959f656 | 2017-02-07 11:03:46 -0500 | [diff] [blame] | 77 | map the current uid to root inside the user namespace. |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 78 | .TP |
Jorge Lucangeli Obes | 959f656 | 2017-02-07 11:03:46 -0500 | [diff] [blame] | 79 | \fB-M[<uid> <loweruid> <count>[,<uid> <loweruid> <count>]]\fR |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 80 | Set the gid mapping of a user namespace (implies \fB-pU\fR). Same arguments as |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 81 | \fBnewgidmap\fR(1). Multiple mappings should be separated by ','. With no mapping, |
Jorge Lucangeli Obes | 959f656 | 2017-02-07 11:03:46 -0500 | [diff] [blame] | 82 | map the current gid to root inside the user namespace. |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 83 | .TP |
Brian Norris | 3b5841b | 2016-03-16 16:43:49 -0700 | [diff] [blame] | 84 | \fB-n\fR |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 85 | Set the process's \fIno_new_privs\fR bit. See \fBprctl\fR(2) and the kernel |
Brian Norris | 3b5841b | 2016-03-16 16:43:49 -0700 | [diff] [blame] | 86 | source file \fIDocumentation/prctl/no_new_privs.txt\fR for more info. |
| 87 | .TP |
Dylan Reid | 87e5851 | 2016-07-11 14:35:12 -0700 | [diff] [blame] | 88 | \fB-N\fR |
| 89 | Run inside a new cgroup namespace. This option runs the program with a cgroup |
| 90 | view showing the program's cgroup as the root. This is only available on v4.6+ |
| 91 | of the Linux kernel. |
| 92 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 93 | \fB-p\fR |
| 94 | Run inside a new PID namespace. This option will make it impossible for the |
Elly Jones | e58176c | 2012-01-23 11:46:17 -0500 | [diff] [blame] | 95 | program to see or affect processes that are not its descendants. This implies |
| 96 | \fB-v\fR and \fB-r\fR, since otherwise the process can see outside its namespace |
| 97 | by inspecting /proc. |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 98 | .TP |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 99 | \fB-P <dir>\fR |
| 100 | Set \fIdir\fR as the root fs using \fBpivot_root\fR. Implies \fB-v\fR, not |
| 101 | compatible with \fB-C\fR. |
| 102 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 103 | \fB-r\fR |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 104 | Remount /proc readonly. This implies \fB-v\fR. Remounting /proc readonly means |
| 105 | that even if the process has write access to a system config knob in /proc |
| 106 | (e.g., in /sys/kernel), it cannot change the value. |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 107 | .TP |
Dylan Reid | 0f72ef4 | 2017-06-06 15:42:49 -0700 | [diff] [blame] | 108 | \fB-R <rlim_type, rlim_cur, rlim_max>\fR |
| 109 | Set an rlimit value, see \fBgetrlimit\fR(2) for allowed values. |
| 110 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 111 | \fB-s\fR |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 112 | Enable \fBseccomp\fR(2) in mode 1, which restricts the child process to a very |
| 113 | small set of system calls. |
Mike Frysinger | e61fd66 | 2017-06-20 14:07:41 -0400 | [diff] [blame] | 114 | You most likely do not want to use this with the seccomp filter mode (\fB-S\fR) |
| 115 | as they are completely different (even though they have similar names). |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 116 | .TP |
| 117 | \fB-S <arch-specific seccomp_filter policy file>\fR |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 118 | Enable \fBseccomp\fR(2) in mode 13 which restricts the child process to a set of |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 119 | system calls defined in the policy file. Note that system calls often change |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 120 | names based on the architecture or mode. (uname -m is your friend.) |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 121 | .TP |
Jorge Lucangeli Obes | 959f656 | 2017-02-07 11:03:46 -0500 | [diff] [blame] | 122 | \fB-t[size]\fR |
Mike Frysinger | ec7def2 | 2017-01-13 18:44:45 -0500 | [diff] [blame] | 123 | Mounts a tmpfs filesystem on /tmp. /tmp must exist already (e.g. in the chroot). |
Martin Pelikán | ab9eb44 | 2017-01-25 11:53:58 +1100 | [diff] [blame] | 124 | The filesystem has a default size of "64M", overridden with an optional |
| 125 | argument. It has standard /tmp permissions (1777), and is mounted |
| 126 | nodev/noexec/nosuid. Implies \fB-v\fR. |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 127 | .TP |
Matthew Dempsky | 2ed0912 | 2016-02-11 09:43:37 -0800 | [diff] [blame] | 128 | \fB-T <type>\fR |
| 129 | Assume program's ELF linkage type is \fItype\fR, |
| 130 | which should be either 'static' or 'dynamic'. |
| 131 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 132 | \fB-u <user>\fR |
| 133 | Change users to \fIuser\fR, which may be either a user name or a numeric user |
| 134 | ID. |
| 135 | .TP |
Brian Norris | 3b5841b | 2016-03-16 16:43:49 -0700 | [diff] [blame] | 136 | \fB-U\fR |
| 137 | Enter a new user namespace (implies \fB-p\fR). |
| 138 | .TP |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 139 | \fB-v\fR |
| 140 | Run inside a new VFS namespace. This option makes the program's mountpoints |
| 141 | independent of the rest of the system's. |
Dylan Reid | 6cae0b2 | 2015-11-18 18:47:49 -0800 | [diff] [blame] | 142 | .TP |
| 143 | \fB-V <file>\fR |
| 144 | Enter the VFS namespace specified by \fIfile\fR. |
Jorge Lucangeli Obes | 1365061 | 2016-09-02 11:27:29 -0400 | [diff] [blame] | 145 | .TP |
Chirantan Ekbote | 866bb3a | 2017-02-07 12:26:42 -0800 | [diff] [blame] | 146 | \fB-w\fR |
| 147 | Create and join a new anonymous session keyring. See \fBkeyrings\fR(7) for more |
| 148 | details. |
| 149 | .TP |
Lutz Justen | 13807cb | 2017-01-03 17:11:55 +0100 | [diff] [blame] | 150 | \fB-y\fR |
| 151 | Keep the current user's supplementary groups. |
| 152 | .TP |
Jorge Lucangeli Obes | 1365061 | 2016-09-02 11:27:29 -0400 | [diff] [blame] | 153 | \fB-Y\fR |
| 154 | Synchronize seccomp filters across thread group. |
Mike Frysinger | b9a7b16 | 2017-05-30 15:25:49 -0400 | [diff] [blame] | 155 | .TP |
| 156 | \fB--uts[=hostname]\fR |
| 157 | Create a new UTS/hostname namespace, and optionally set the hostname in the new |
| 158 | namespace to \fIhostname\fR. |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 159 | .SH IMPLEMENTATION |
| 160 | This program is broken up into two parts: \fBminijail0\fR (the frontend) and a helper |
| 161 | library called \fBlibminijailpreload\fR. Some jailings can only be achieved from |
| 162 | the process to which they will actually apply - specifically capability use |
| 163 | (since capabilities are not inherited to an exec'd process unless the exec'd |
| 164 | process has POSIX file capabilities), seccomp (since we can't exec() once we're |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 165 | seccomp'd), and ptrace-disable (which is always cleared on exec()). |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 166 | |
| 167 | To this end, \fBlibminijailpreload\fR is forcibly loaded into all |
| 168 | dynamically-linked target programs if any of these restrictions are in effect; |
| 169 | we pass the specific restrictions in an environment variable which the preloaded |
| 170 | library looks for. The forcibly-loaded library then applies the restrictions |
| 171 | to the newly-loaded program. |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 172 | |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 173 | .SH AUTHOR |
Jorge Lucangeli Obes | a521bee | 2016-03-03 13:47:57 -0800 | [diff] [blame] | 174 | The Chromium OS Authors <chromiumos-dev@chromium.org> |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 175 | .SH COPYRIGHT |
| 176 | Copyright \(co 2011 The Chromium OS Authors |
| 177 | License BSD-like. |
| 178 | .SH "SEE ALSO" |
Mike Frysinger | 0fe4e4f | 2017-06-20 14:01:09 -0400 | [diff] [blame] | 179 | \fBlibminijail.h\fR \fBminijail0\fR(5) |