From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6108C7EE24 for ; Tue, 6 Jun 2023 14:39:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238070AbjFFOjF (ORCPT ); Tue, 6 Jun 2023 10:39:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238195AbjFFOiT (ORCPT ); Tue, 6 Jun 2023 10:38:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A2919BA for ; Tue, 6 Jun 2023 07:37:52 -0700 (PDT) Message-ID: <20230606142032.151323086@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686062270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Oszm2ZXBXWLXUTPr0v8LyoBnFHycifs2Z0aI1dsyju0=; b=D0ntuw5CvYsxl7SSpv78NSEO1OXove23skoVb9/culdydz2S3W/9AodOxMk18vwf/Sda8X PLJ+JN27N/9vZ/ZbfB4sfPzgijMO/Czl53luFkcn4sIF4hJJcmNPGHjzTsXxzCTuQXM/8N dVHffqboWgZ/JDXz5LZmHKgSfX30JvUl6sWrLznm6Gq8WUW9vvZvUIF7Ubzq7vYct7mHgY +oow8XxaFw958QPoqnCvgEGlpcHVj22vj1yHcS7Yg4+2vkOHWiq3s4w8X+RGdZSVeFy45v 5lYPgme3D0nI8L6FjetOVpodb/vsthI08TeP63e4ezMc159nfQ853OizEUzDEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686062270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Oszm2ZXBXWLXUTPr0v8LyoBnFHycifs2Z0aI1dsyju0=; b=5htpoKmcrRXlS0Nl4wNjcwhNX8aRSMwzaKf44yg10U6SoWgH0XxX8TaMn1da7IsgGlX4ih 8rmcZVlqOixyvoDQ== From: Thomas Gleixner To: LKML Cc: Frederic Weisbecker , Anna-Maria Behnsen , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch 20/45] signal: Replace BUG_ON()s References: <20230606132949.068951363@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 6 Jun 2023 16:37:50 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These really can be handled gracefully without killing the machine. Signed-off-by: Thomas Gleixner --- kernel/signal.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1932,10 +1932,11 @@ struct sigqueue *sigqueue_alloc(void) void sigqueue_free(struct sigqueue *q) { - unsigned long flags; spinlock_t *lock = ¤t->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 @@ -1963,7 +1964,10 @@ int send_sigqueue(struct sigqueue *q, st 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(); @@ -1998,7 +2002,6 @@ int send_sigqueue(struct sigqueue *q, st * 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;