diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-08-10 23:50:30 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2014-08-11 16:29:12 -0400 |
commit | 69f6a34bdeea4fec50bb90619bc9602973119572 (patch) | |
tree | 8fb595069ac3490438244ca28076b7c1837f93d8 /kernel/seccomp.c | |
parent | c8d6637d0497d62093dbba0694c7b3a80b79bfe1 (diff) |
seccomp: Replace BUG(!spin_is_locked()) with assert_spin_lock
Current upstream kernel hangs with mips and powerpc targets in
uniprocessor mode if SECCOMP is configured.
Bisect points to commit dbd952127d11 ("seccomp: introduce writer locking").
Turns out that code such as
BUG_ON(!spin_is_locked(&list_lock));
can not be used in uniprocessor mode because spin_is_locked() always
returns false in this configuration, and that assert_spin_locked()
exists for that very purpose and must be used instead.
Fixes: dbd952127d11 ("seccomp: introduce writer locking")
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'kernel/seccomp.c')
-rw-r--r-- | kernel/seccomp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 25b0043f4755..44eb005c6695 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
@@ -203,7 +203,7 @@ static u32 seccomp_run_filters(int syscall) | |||
203 | 203 | ||
204 | static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode) | 204 | static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode) |
205 | { | 205 | { |
206 | BUG_ON(!spin_is_locked(¤t->sighand->siglock)); | 206 | assert_spin_locked(¤t->sighand->siglock); |
207 | 207 | ||
208 | if (current->seccomp.mode && current->seccomp.mode != seccomp_mode) | 208 | if (current->seccomp.mode && current->seccomp.mode != seccomp_mode) |
209 | return false; | 209 | return false; |
@@ -214,7 +214,7 @@ static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode) | |||
214 | static inline void seccomp_assign_mode(struct task_struct *task, | 214 | static inline void seccomp_assign_mode(struct task_struct *task, |
215 | unsigned long seccomp_mode) | 215 | unsigned long seccomp_mode) |
216 | { | 216 | { |
217 | BUG_ON(!spin_is_locked(&task->sighand->siglock)); | 217 | assert_spin_locked(&task->sighand->siglock); |
218 | 218 | ||
219 | task->seccomp.mode = seccomp_mode; | 219 | task->seccomp.mode = seccomp_mode; |
220 | /* | 220 | /* |
@@ -253,7 +253,7 @@ static inline pid_t seccomp_can_sync_threads(void) | |||
253 | struct task_struct *thread, *caller; | 253 | struct task_struct *thread, *caller; |
254 | 254 | ||
255 | BUG_ON(!mutex_is_locked(¤t->signal->cred_guard_mutex)); | 255 | BUG_ON(!mutex_is_locked(¤t->signal->cred_guard_mutex)); |
256 | BUG_ON(!spin_is_locked(¤t->sighand->siglock)); | 256 | assert_spin_locked(¤t->sighand->siglock); |
257 | 257 | ||
258 | /* Validate all threads being eligible for synchronization. */ | 258 | /* Validate all threads being eligible for synchronization. */ |
259 | caller = current; | 259 | caller = current; |
@@ -294,7 +294,7 @@ static inline void seccomp_sync_threads(void) | |||
294 | struct task_struct *thread, *caller; | 294 | struct task_struct *thread, *caller; |
295 | 295 | ||
296 | BUG_ON(!mutex_is_locked(¤t->signal->cred_guard_mutex)); | 296 | BUG_ON(!mutex_is_locked(¤t->signal->cred_guard_mutex)); |
297 | BUG_ON(!spin_is_locked(¤t->sighand->siglock)); | 297 | assert_spin_locked(¤t->sighand->siglock); |
298 | 298 | ||
299 | /* Synchronize all threads. */ | 299 | /* Synchronize all threads. */ |
300 | caller = current; | 300 | caller = current; |
@@ -464,7 +464,7 @@ static long seccomp_attach_filter(unsigned int flags, | |||
464 | unsigned long total_insns; | 464 | unsigned long total_insns; |
465 | struct seccomp_filter *walker; | 465 | struct seccomp_filter *walker; |
466 | 466 | ||
467 | BUG_ON(!spin_is_locked(¤t->sighand->siglock)); | 467 | assert_spin_locked(¤t->sighand->siglock); |
468 | 468 | ||
469 | /* Validate resulting filter length. */ | 469 | /* Validate resulting filter length. */ |
470 | total_insns = filter->prog->len; | 470 | total_insns = filter->prog->len; |