Browse Source

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

Pull seccomp fix from James Morris.

BUG(!spin_is_locked()) really doesn't work very well in UP
configurations without any actual spinlock state.  Which is very much
why we have that "assert_spin_lock()" function for this.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  seccomp: Replace BUG(!spin_is_locked()) with assert_spin_lock
Linus Torvalds 11 years ago
parent
commit
311bf6d1cb
2 changed files with 6 additions and 6 deletions
  1. 1 1
      kernel/fork.c
  2. 5 5
      kernel/seccomp.c

+ 1 - 1
kernel/fork.c

@@ -1105,7 +1105,7 @@ static void copy_seccomp(struct task_struct *p)
 	 * needed because this new task is not yet running and cannot
 	 * needed because this new task is not yet running and cannot
 	 * be racing exec.
 	 * be racing exec.
 	 */
 	 */
-	BUG_ON(!spin_is_locked(&current->sighand->siglock));
+	assert_spin_locked(&current->sighand->siglock);
 
 
 	/* Ref-count the new filter user, and assign it. */
 	/* Ref-count the new filter user, and assign it. */
 	get_seccomp_filter(current);
 	get_seccomp_filter(current);

+ 5 - 5
kernel/seccomp.c

@@ -203,7 +203,7 @@ static u32 seccomp_run_filters(int syscall)
 
 
 static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
 static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
 {
 {
-	BUG_ON(!spin_is_locked(&current->sighand->siglock));
+	assert_spin_locked(&current->sighand->siglock);
 
 
 	if (current->seccomp.mode && current->seccomp.mode != seccomp_mode)
 	if (current->seccomp.mode && current->seccomp.mode != seccomp_mode)
 		return false;
 		return false;
@@ -214,7 +214,7 @@ static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
 static inline void seccomp_assign_mode(struct task_struct *task,
 static inline void seccomp_assign_mode(struct task_struct *task,
 				       unsigned long seccomp_mode)
 				       unsigned long seccomp_mode)
 {
 {
-	BUG_ON(!spin_is_locked(&task->sighand->siglock));
+	assert_spin_locked(&task->sighand->siglock);
 
 
 	task->seccomp.mode = seccomp_mode;
 	task->seccomp.mode = seccomp_mode;
 	/*
 	/*
@@ -253,7 +253,7 @@ static inline pid_t seccomp_can_sync_threads(void)
 	struct task_struct *thread, *caller;
 	struct task_struct *thread, *caller;
 
 
 	BUG_ON(!mutex_is_locked(&current->signal->cred_guard_mutex));
 	BUG_ON(!mutex_is_locked(&current->signal->cred_guard_mutex));
-	BUG_ON(!spin_is_locked(&current->sighand->siglock));
+	assert_spin_locked(&current->sighand->siglock);
 
 
 	/* Validate all threads being eligible for synchronization. */
 	/* Validate all threads being eligible for synchronization. */
 	caller = current;
 	caller = current;
@@ -294,7 +294,7 @@ static inline void seccomp_sync_threads(void)
 	struct task_struct *thread, *caller;
 	struct task_struct *thread, *caller;
 
 
 	BUG_ON(!mutex_is_locked(&current->signal->cred_guard_mutex));
 	BUG_ON(!mutex_is_locked(&current->signal->cred_guard_mutex));
-	BUG_ON(!spin_is_locked(&current->sighand->siglock));
+	assert_spin_locked(&current->sighand->siglock);
 
 
 	/* Synchronize all threads. */
 	/* Synchronize all threads. */
 	caller = current;
 	caller = current;
@@ -464,7 +464,7 @@ static long seccomp_attach_filter(unsigned int flags,
 	unsigned long total_insns;
 	unsigned long total_insns;
 	struct seccomp_filter *walker;
 	struct seccomp_filter *walker;
 
 
-	BUG_ON(!spin_is_locked(&current->sighand->siglock));
+	assert_spin_locked(&current->sighand->siglock);
 
 
 	/* Validate resulting filter length. */
 	/* Validate resulting filter length. */
 	total_insns = filter->prog->len;
 	total_insns = filter->prog->len;