signal: Use lockdep_assert_held instead of assert_spin_locked
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 29 Apr 2022 14:16:10 +0000 (09:16 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 11 May 2022 19:34:14 +0000 (14:34 -0500)
The distinction is that assert_spin_locked() checks if the lock is
held *by*anyone* whereas lockdep_assert_held() asserts the current
context holds the lock.  Also, the check goes away if you build
without lockdep.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/Ympr/+PX4XgT/UKU@hirez.programming.kicks-ass.net
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lkml.kernel.org/r/20220505182645.497868-6-ebiederm@xmission.com
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
kernel/signal.c

index 72d96614effc588ca64ca9bb826cb7aa52cf1291..3fd2ce13338790c1520b979045f2ee0c6041a961 100644 (file)
@@ -884,7 +884,7 @@ static int check_kill_permission(int sig, struct kernel_siginfo *info,
 static void ptrace_trap_notify(struct task_struct *t)
 {
        WARN_ON_ONCE(!(t->ptrace & PT_SEIZED));
-       assert_spin_locked(&t->sighand->siglock);
+       lockdep_assert_held(&t->sighand->siglock);
 
        task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY);
        ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);
@@ -1079,7 +1079,7 @@ static int __send_signal_locked(int sig, struct kernel_siginfo *info,
        int override_rlimit;
        int ret = 0, result;
 
-       assert_spin_locked(&t->sighand->siglock);
+       lockdep_assert_held(&t->sighand->siglock);
 
        result = TRACE_SIGNAL_IGNORED;
        if (!prepare_signal(sig, t, force))