aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJann Horn <jann@thejh.net>2015-12-26 06:00:48 +0100
committerKees Cook <keescook@google.com>2016-04-08 12:49:21 -0700
commitb0f3cdf057ad85790d0739130443b01e71040d01 (patch)
tree0ad08fd14054e49505997e0fd09b7ab4cd1cd08c
parent46e76b0c807df39c2220f5dbb92075157d2dfe63 (diff)
downloadqcom-msm-v3.10-master.tar.gz
UPSTREAM: seccomp: always propagate NO_NEW_PRIVS on tsyncHEADmastermain
Before this patch, a process with some permissive seccomp filter that was applied by root without NO_NEW_PRIVS was able to add more filters to itself without setting NO_NEW_PRIVS by setting the new filter from a throwaway thread with NO_NEW_PRIVS. Signed-off-by: Jann Horn <jann@thejh.net> Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Bug: 28020023 Patchset: seccomp (cherry picked from commit 103502a35cfce0710909da874f092cb44823ca03) Signed-off-by: Kees Cook <keescook@google.com> Change-Id: Ie7cd72d68d72699d4923b665f1d0af55e7ac5024
-rw-r--r--kernel/seccomp.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 39cdd735c0f..5fc8fcdd93a 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -342,24 +342,24 @@ static inline void seccomp_sync_threads(void)
put_seccomp_filter(thread);
smp_store_release(&thread->seccomp.filter,
caller->seccomp.filter);
+
+ /*
+ * Don't let an unprivileged task work around
+ * the no_new_privs restriction by creating
+ * a thread that sets it up, enters seccomp,
+ * then dies.
+ */
+ if (task_no_new_privs(caller))
+ task_set_no_new_privs(thread);
+
/*
* Opt the other thread into seccomp if needed.
* As threads are considered to be trust-realm
* equivalent (see ptrace_may_access), it is safe to
* allow one thread to transition the other.
*/
- if (thread->seccomp.mode == SECCOMP_MODE_DISABLED) {
- /*
- * Don't let an unprivileged task work around
- * the no_new_privs restriction by creating
- * a thread that sets it up, enters seccomp,
- * then dies.
- */
- if (task_no_new_privs(caller))
- task_set_no_new_privs(thread);
-
+ if (thread->seccomp.mode == SECCOMP_MODE_DISABLED)
seccomp_assign_mode(thread, SECCOMP_MODE_FILTER);
- }
}
}