Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3878996rwb; Sat, 21 Jan 2023 01:55:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXu/STtNX08yQtEWGhROJNpLvM9la29FvpVN9ri6Nk9Z+NdE0fVFeGveXxz1TzV3Qav/aVZR X-Received: by 2002:aa7:d9d1:0:b0:46c:b25a:6d7f with SMTP id v17-20020aa7d9d1000000b0046cb25a6d7fmr31763964eds.8.1674294950964; Sat, 21 Jan 2023 01:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674294950; cv=none; d=google.com; s=arc-20160816; b=BjZrB6qaTdKOCM9pmN806afk5SlXjUee4j16HTMq/x6kPeQ11zdZkp+Z514k6qAT+a ycOGBCsOOAq4M3Llei7tWV6z2KJtB8G2bchaDLNz34rHTvPU9Cp/08b+5dQKa8ZpJ1ma JvFZ1MuMSC4ogHFn7kIm7c2dA9zm4s+yzXE7sIWdASS2xRZ93cXuuMMLYK6Fl+Yarlo8 akmEM9iGGBAr/guS/7NGDK/DoyPti0tvmZVhOOjShZLutdlRGU3xvH/CVOMF9/a9R8IQ Oe1idyadhydPHwfFkJQ8xAZHMetKdXClEEVARtZB6otbhuOLyX/os+PxUJolwzgBJhD5 9Fbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=IbbhcF8jjbhatiPNBh3NGG62KRGU4zaxGafUDJYl9Xo=; b=W/12yquGf+J26MmPD3JTniNCZ8GmouXkb6wQ+5WoIl9O/eMt6A+n8HYZkSiqhwMDQD +aavGAsXpHOfxoOBrHZpGWbSqluR1K8pQ4phRkq+K8iRcK/HN0tyMBIsqeujM6OV7q8J 3AK2pdcLahZFXnKm+21NclJE+ccxFi7S2Sa/hf5tPzI+62Okir1bhOPy2sqN7iYSuTY4 Z8riH0/zq3P+Pzxb7hD0jSgExXUG1Zm6je1DexiOSWNz22d2JGzHaP+Ok3HZ57Thd+JC Hrqa2dgWFcJIkEj+VN0D66+2tAz0n9Ygmc4M+ZKaQP7BKxzXeKg+MXzpIpnohwHcGkgP syCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3qdi+WCe; dkim=neutral (no key) header.i=@linutronix.de header.b="rty5S76/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p6-20020a05640243c600b0049e267d9398si14588559edc.327.2023.01.21.01.55.38; Sat, 21 Jan 2023 01:55:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3qdi+WCe; dkim=neutral (no key) header.i=@linutronix.de header.b="rty5S76/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbjAUJt6 (ORCPT + 50 others); Sat, 21 Jan 2023 04:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbjAUJtj (ORCPT ); Sat, 21 Jan 2023 04:49:39 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754205C0FD; Sat, 21 Jan 2023 01:49:38 -0800 (PST) Date: Sat, 21 Jan 2023 09:49:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1674294577; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IbbhcF8jjbhatiPNBh3NGG62KRGU4zaxGafUDJYl9Xo=; b=3qdi+WCe7F+binSuegDbdFWwtU6R5n49zTlkJ4OQI9qZbjLigiIBGhaDb8eT/hYKFtOHqt 096KIQXmTYg9Lqu+Hxt5rU76EC8cwRXHzfNRZL930XMIB4x6oSFINqYdHXN6aJ2QJx5Ym/ zTDQz5WezMTe2VrEnnR1A1uv/xdN2Ii4ZQC8BauktC/lEbr5lglMQthvFW3+npnNm9J86S R8t5iItd7KxDvmoURglFWukbl2ZK+A1ATS10DhV5CgtWThWJmlZOausUUfdCGCFoI0Bzmt Vs4KiWlNTeu4xJ/fNU8HXb76XoZMW+eXCX5pvMa341U28VDvyDYRzvbZDmIp4w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1674294577; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IbbhcF8jjbhatiPNBh3NGG62KRGU4zaxGafUDJYl9Xo=; b=rty5S76/5R5b00dXHLgRjXA43kXY9IMoRjtQNj+Q+YSpFzPtq9ywb2RGjAeR07Z23bifWb SDZbxU5AE7tSkfBg== From: "tip-bot2 for Nicholas Piggin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] exit: Detect and fix irq disabled state in oops Cc: Michael Ellerman , Nicholas Piggin , "Peter Zijlstra (Intel)" , "Eric W. Biederman" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167429457670.4906.17321070796908774567.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 001c28e57187570e4b5aa4492c7a957fb6d65d7b Gitweb: https://git.kernel.org/tip/001c28e57187570e4b5aa4492c7a957fb6d65d7b Author: Nicholas Piggin AuthorDate: Fri, 20 Jan 2023 11:18:20 +10:00 Committer: Peter Zijlstra CommitterDate: Sat, 21 Jan 2023 00:06:10 +01:00 exit: Detect and fix irq disabled state in oops If a task oopses with irqs disabled, this can cause various cascading problems in the oops path such as sleep-from-invalid warnings, and potentially worse. Since commit 0258b5fd7c712 ("coredump: Limit coredumps to a single thread group"), the unconditional irq enable in coredump_task_exit() will "fix" the irq state to be enabled early in do_exit(), so currently this may not be triggerable, but that is coincidental and fragile. Detect and fix the irqs_disabled() condition in the oops path before calling do_exit(), similarly to the way in_atomic() is handled. Reported-by: Michael Ellerman Signed-off-by: Nicholas Piggin Signed-off-by: Peter Zijlstra (Intel) Acked-by: "Eric W. Biederman" Link: https://lore.kernel.org/lkml/20221004094401.708299-1-npiggin@gmail.com/ --- kernel/exit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/exit.c b/kernel/exit.c index 15dc2ec..bccfa42 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -807,6 +807,8 @@ void __noreturn do_exit(long code) struct task_struct *tsk = current; int group_dead; + WARN_ON(irqs_disabled()); + synchronize_group_exit(tsk, code); WARN_ON(tsk->plug); @@ -938,6 +940,11 @@ void __noreturn make_task_dead(int signr) if (unlikely(!tsk->pid)) panic("Attempted to kill the idle task!"); + if (unlikely(irqs_disabled())) { + pr_info("note: %s[%d] exited with irqs disabled\n", + current->comm, task_pid_nr(current)); + local_irq_enable(); + } if (unlikely(in_atomic())) { pr_info("note: %s[%d] exited with preempt_count %d\n", current->comm, task_pid_nr(current),