]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
signal: Replace BUG_ON()s
authorThomas Gleixner <tglx@linutronix.de>
Mon, 10 Jun 2024 16:42:34 +0000 (18:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:08:12 +0000 (15:08 +0200)
[ Upstream commit 7f8af7bac5380f2d95a63a6f19964e22437166e1 ]

These really can be handled gracefully without killing the machine.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/signal.c

index bfc1da526ebbe7aaea03170cd91f342f269a950d..7a9af6d4f2b01ee16ebb80f85872356b54e7b665 100644 (file)
@@ -1817,10 +1817,11 @@ struct sigqueue *sigqueue_alloc(void)
 
 void sigqueue_free(struct sigqueue *q)
 {
-       unsigned long flags;
        spinlock_t *lock = &current->sighand->siglock;
+       unsigned long flags;
 
-       BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
+       if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC)))
+               return;
        /*
         * We must hold ->siglock while testing q->list
         * to serialize with collect_signal() or with
@@ -1848,7 +1849,10 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
        unsigned long flags;
        int ret, result;
 
-       BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
+       if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC)))
+               return 0;
+       if (WARN_ON_ONCE(q->info.si_code != SI_TIMER))
+               return 0;
 
        ret = -1;
        rcu_read_lock();
@@ -1867,7 +1871,6 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
                 * If an SI_TIMER entry is already queue just increment
                 * the overrun count.
                 */
-               BUG_ON(q->info.si_code != SI_TIMER);
                q->info.si_overrun++;
                result = TRACE_SIGNAL_ALREADY_PENDING;
                goto out;