seccomp: do not reject initial filter using TSYNC
PATCH 1/1 seccomp: do not reject initial filter using TSYNC
There was an unneeded sanity check in the TSYNC code that was causing the first filter applied to not allow the TSYNC flag. Additionally, this optimizes the thread loops to skip "current". It was harmless, but better to not cause problems in the future.
---
This goes on top of the v11 seccomp-tsync series. If I should respin as v12, please let me know.
Thanks!
--- kernel/seccomp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/seccomp.c +8 -3
@@ -255,14 +255,15 @@ static inline pid_t seccomp_can_sync_threads(void)BUG_ON (!mutex_is_locked (¤t->signal->cred_guard_mutex));BUG_ON (!spin_is_locked (¤t->sighand->siglock)); -if (current->seccomp.mode !=SECCOMP_MODE_FILTER ) -return -EACCES ; -/* Validate all threads being eligible for synchronization. */ caller = current; for_each_thread(caller, thread) { pid_t failed; + /* Skip current, since it is initiating the sync. */ + if (thread == current) + continue; + if (thread->seccomp.mode == SECCOMP_MODE_DISABLED || (thread->seccomp.mode == SECCOMP_MODE_FILTER && is_ancestor(thread->seccomp.filter,
@@ -298,6 +299,10 @@ static inline void seccomp_sync_threads(void)/* Synchronize all threads. */ caller = current;for_each_thread (caller, thread) { +/* Skip current, since it needs no changes. */ +if (thread == current) +continue ; +/* Get a task reference for the new leaf node. */ get_seccomp_filter (caller);/*
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security
Andy Lutomirski
reviewerQuoted 26 lines · Kees Cook
There was an unneeded sanity check in the TSYNC code that was causing the first filter applied to not allow the TSYNC flag. Additionally, this optimizes the thread loops to skip "current". It was harmless, but better to not cause problems in the future.
Reported-by David Drysdale <[email protected]>Signed-off-by Kees Cook <[email protected]>---
This goes on top of the v11 seccomp-tsync series. If I should respin as v12, please let me know.Thanks!
--- kernel/seccomp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)kernel/seccomp.c +0
-2@@ -255,14 +255,15 @@ static inline pid_t seccomp_can_sync_threads(void)BUG_ON (!mutex_is_locked (¤t->signal->cred_guard_mutex));BUG_ON (!spin_is_locked (¤t->sighand->siglock)); -if (current->seccomp.mode !=SECCOMP_MODE_FILTER ) -return -EACCES ;
kernel/seccomp.c static inline pid_t seccomp_can_sync_threads(void) · line 266
Quoted 10 lines
kernel/seccomp.c +4
-1-/* Validate all threads being eligible for synchronization. */ caller = current;for_each_thread (caller, thread) {pid_t failed; +/* Skip current, since it is initiating the sync. */ +if (thread == current) +continue ; +
Should that be "thread == caller"?
--Andy
Quoted 33 lines · Andy Lutomirski
Quoted 32 lines · Kees Cook
There was an unneeded sanity check in the TSYNC code that was causing the first filter applied to not allow the TSYNC flag. Additionally, this optimizes the thread loops to skip "current". It was harmless, but better to not cause problems in the future.
Reported-by David Drysdale <[email protected]>Signed-off-by Kees Cook <[email protected]>---
This goes on top of the v11 seccomp-tsync series. If I should respin as v12, please let me know.Thanks!
--- kernel/seccomp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)kernel/seccomp.c +0
-3@@ -255,14 +255,15 @@ static inline pid_t seccomp_can_sync_threads(void)BUG_ON (!mutex_is_locked (¤t->signal->cred_guard_mutex));BUG_ON (!spin_is_locked (¤t->sighand->siglock)); -if (current->seccomp.mode !=SECCOMP_MODE_FILTER ) -return -EACCES ; -/* Validate all threads being eligible for synchronization. */ caller = current;for_each_thread (caller, thread) {pid_t failed;
Quoted 6 lines
kernel/seccomp.c static inline pid_t seccomp_can_sync_threads(void) · line 266
Quoted 4 lines
kernel/seccomp.c +4
-0+/* Skip current, since it is initiating the sync. */ +if (thread == current) +continue ; +Should that be "thread == caller"?
caller shouldn't be changing, correct? Won't it be the same?
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
Andy Lutomirski
reviewerQuoted 34 lines · Kees Cook
Quoted 33 lines · Andy Lutomirski
Quoted 32 lines · Kees Cook
There was an unneeded sanity check in the TSYNC code that was causing the first filter applied to not allow the TSYNC flag. Additionally, this optimizes the thread loops to skip "current". It was harmless, but better to not cause problems in the future.
Reported-by David Drysdale <[email protected]>Signed-off-by Kees Cook <[email protected]>---
This goes on top of the v11 seccomp-tsync series. If I should respin as v12, please let me know.Thanks!
--- kernel/seccomp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)kernel/seccomp.c +0
-3@@ -255,14 +255,15 @@ static inline pid_t seccomp_can_sync_threads(void)BUG_ON (!mutex_is_locked (¤t->signal->cred_guard_mutex));BUG_ON (!spin_is_locked (¤t->sighand->siglock)); -if (current->seccomp.mode !=SECCOMP_MODE_FILTER ) -return -EACCES ; -/* Validate all threads being eligible for synchronization. */ caller = current;for_each_thread (caller, thread) {pid_t failed;
Quoted 9 lines
Quoted 6 lines
kernel/seccomp.c static inline pid_t seccomp_can_sync_threads(void) · line 266
Quoted 4 lines
kernel/seccomp.c +4
-0+/* Skip current, since it is initiating the sync. */ +if (thread == current) +continue ; +Should that be "thread == caller"?
caller shouldn't be changing, correct? Won't it be the same?
I assumed that you loaded caller once as an optimization -- ISTR that, at least at some point, accessing current was a slightly expensive. Maybe this is moot now.
Anyway, the rest of the code in there is comparing thread to caller, using caller seems a bit more consistent.
--Andy
Quoted 5 lines
-Kees
--
Kees Cook
Chrome OS Security
Signature · 2 lines
Andy Lutomirski AMA Capital Management, LLC
Quoted 45 lines · Andy Lutomirski
Quoted 34 lines · Kees Cook
Quoted 33 lines · Andy Lutomirski
Quoted 32 lines · Kees Cook
There was an unneeded sanity check in the TSYNC code that was causing the first filter applied to not allow the TSYNC flag. Additionally, this optimizes the thread loops to skip "current". It was harmless, but better to not cause problems in the future.
Reported-by David Drysdale <[email protected]>Signed-off-by Kees Cook <[email protected]>---
This goes on top of the v11 seccomp-tsync series. If I should respin as v12, please let me know.Thanks!
--- kernel/seccomp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)kernel/seccomp.c +0
-3@@ -255,14 +255,15 @@ static inline pid_t seccomp_can_sync_threads(void)BUG_ON (!mutex_is_locked (¤t->signal->cred_guard_mutex));BUG_ON (!spin_is_locked (¤t->sighand->siglock)); -if (current->seccomp.mode !=SECCOMP_MODE_FILTER ) -return -EACCES ; -/* Validate all threads being eligible for synchronization. */ caller = current;for_each_thread (caller, thread) {pid_t failed;Quoted 9 lines
Quoted 6 lines
kernel/seccomp.c static inline pid_t seccomp_can_sync_threads(void) · line 266
Quoted 4 lines
kernel/seccomp.c +4
-0+/* Skip current, since it is initiating the sync. */ +if (thread == current) +continue ; +Should that be "thread == caller"?
caller shouldn't be changing, correct? Won't it be the same?
Quoted 6 lines
I assumed that you loaded caller once as an optimization -- ISTR that, at least at some point, accessing current was a slightly expensive. Maybe this is moot now.
Anyway, the rest of the code in there is comparing thread to caller, using caller seems a bit more consistent.
Fair enough. :)
I'll resend with this folded in for a v12.
Thanks!
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security