diff options
author | Andy Lutomirski <luto@amacapital.net> | 2012-04-12 17:47:50 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2012-04-13 21:13:18 -0400 |
commit | 259e5e6c75a910f3b5e656151dc602f53f9d7548 (patch) | |
tree | 4405fdf68238f2e33f27b04e8c37c9e29a2493d8 /include/linux/prctl.h | |
parent | 9ccf010f8172b699ea80178860e8ea228f7dce56 (diff) |
Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs
With this change, calling
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)
disables privilege granting operations at execve-time. For example, a
process will not be able to execute a setuid binary to change their uid
or gid if this bit is set. The same is true for file capabilities.
Additionally, LSM_UNSAFE_NO_NEW_PRIVS is defined to ensure that
LSMs respect the requested behavior.
To determine if the NO_NEW_PRIVS bit is set, a task may call
prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
It returns 1 if set and 0 if it is not set. If any of the arguments are
non-zero, it will return -1 and set errno to -EINVAL.
(PR_SET_NO_NEW_PRIVS behaves similarly.)
This functionality is desired for the proposed seccomp filter patch
series. By using PR_SET_NO_NEW_PRIVS, it allows a task to modify the
system call behavior for itself and its child tasks without being
able to impact the behavior of a more privileged task.
Another potential use is making certain privileged operations
unprivileged. For example, chroot may be considered "safe" if it cannot
affect privileged tasks.
Note, this patch causes execve to fail when PR_SET_NO_NEW_PRIVS is
set and AppArmor is in use. It is fixed in a subsequent patch.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Will Drewry <wad@chromium.org>
Acked-by: Eric Paris <eparis@redhat.com>
Acked-by: Kees Cook <keescook@chromium.org>
v18: updated change desc
v17: using new define values as per 3.4
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'include/linux/prctl.h')
-rw-r--r-- | include/linux/prctl.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/prctl.h b/include/linux/prctl.h index e0cfec2490aa..78b76e24cc7e 100644 --- a/include/linux/prctl.h +++ b/include/linux/prctl.h | |||
@@ -124,4 +124,19 @@ | |||
124 | #define PR_SET_CHILD_SUBREAPER 36 | 124 | #define PR_SET_CHILD_SUBREAPER 36 |
125 | #define PR_GET_CHILD_SUBREAPER 37 | 125 | #define PR_GET_CHILD_SUBREAPER 37 |
126 | 126 | ||
127 | /* | ||
128 | * If no_new_privs is set, then operations that grant new privileges (i.e. | ||
129 | * execve) will either fail or not grant them. This affects suid/sgid, | ||
130 | * file capabilities, and LSMs. | ||
131 | * | ||
132 | * Operations that merely manipulate or drop existing privileges (setresuid, | ||
133 | * capset, etc.) will still work. Drop those privileges if you want them gone. | ||
134 | * | ||
135 | * Changing LSM security domain is considered a new privilege. So, for example, | ||
136 | * asking selinux for a specific new context (e.g. with runcon) will result | ||
137 | * in execve returning -EPERM. | ||
138 | */ | ||
139 | #define PR_SET_NO_NEW_PRIVS 38 | ||
140 | #define PR_GET_NO_NEW_PRIVS 39 | ||
141 | |||
127 | #endif /* _LINUX_PRCTL_H */ | 142 | #endif /* _LINUX_PRCTL_H */ |