Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp848910rwb; Wed, 16 Nov 2022 08:25:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/PpfJoLCHoXN8lGmsgv5J4+ELug+SylcZUeJJXpjindIQpnM9+cgzt3bms+UxhCQF8wrF X-Received: by 2002:a17:906:4e88:b0:7a7:1d4f:c7dc with SMTP id v8-20020a1709064e8800b007a71d4fc7dcmr17965331eju.252.1668615912146; Wed, 16 Nov 2022 08:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615912; cv=none; d=google.com; s=arc-20160816; b=i6ap33M7862zQWJdbots43f9mgGb/T0UD38ldLIxK4D2wOgDAs1Qs7iyn1BN1ksFhy QDvMax5MJbtPJQPvTYSZP0+YUl5TMAh1ryVmzAzL43lf/HRGfrVipms5hSJxH/xvZ0// /623+jgJxGeIEobFiiUKTyt0a8ea9z/sy4KctZKmxt2CEXa257CqDIRgnuNQxpxCyQyy ZVB/3bAZG/BlWvb6+kuWHX3H6+EtLCzz3fva823cZORl27DNQYiEgEWUuXatmdbwUMKs 1NAhAsREHiI+Up2eI+I1GMN0SgBYsk+8TQ94yL2o6Sth7brYOJYYKo6v0BTh8QVvyoc4 Q3fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=eUV7NYFJOYRPWEVh0G/EU6zT1t7HGJ6qLPZoOxwFJX0=; b=MPUEB1sW/lYsLzGIpvQseMG4MAFkDJ/VIclxmkqFqYz4E6TZVOhUvKkRsIKDLk4W4r FJDGR2cRI3ZSud0mNx2wGhz6YEFWWpL3ztePBMIitHNlCZJY7XRzxeMu1QP7CfE1y5Np F+/Bi7h8nULDHsHwTXQBvydQKiYR+MFB6Dk1gYOYQ3nb4JZOyoxxalS223OMfaEiTGUo yrY7Guz2hPpQqvVt/3jVC2BHAcbBpTH491auR2F3YICoF/hfZ8p/p3rZ1fvSRf1/CeH0 tfmBny1mjVwSkrs77C+p3pa0sAlc6nmeyk78Vckg48ZbH9MZaoYPXPfOEtVXHiCyU5x0 Jdxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=i6rR4UWr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 r19-20020a05640251d300b00461c852af19si17155475edd.633.2022.11.16.08.24.49; Wed, 16 Nov 2022 08:25:12 -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=i6rR4UWr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S235008AbiKPQWr (ORCPT + 91 others); Wed, 16 Nov 2022 11:22:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233533AbiKPQWE (ORCPT ); Wed, 16 Nov 2022 11:22:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60129E62 for ; Wed, 16 Nov 2022 08:22:03 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eUV7NYFJOYRPWEVh0G/EU6zT1t7HGJ6qLPZoOxwFJX0=; b=i6rR4UWrVsi6o7VcT0dSMzT5OauKeph8Ma1KOTE1b3BM6zKYwJAEGVd6iEJRPcFdOzFCsV HFHmgCNxA9Fub/V2HRwn5xTn33moUGNvgJO1eRSW7ZjzDCd6FDzinZgDymoEquukHZHHq8 s0CfN3++aC4Wd7OuFwJFvCQsDYHtBi7rsrcCbu9lZoG91wvkVze/0dhNIfwRkt0O7vFlHa rE7O6ZmuYj60l/uRvg4R+LV7hz+mhxPJqdVMQJcBtOHc7Hs81xukaMun6CQZh40u/UZ7RM NeBEbscz4y231v4m1OKF/5nSrs2B2K8EMQ5CSNYZsDingtF4zCMr28jZldooGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eUV7NYFJOYRPWEVh0G/EU6zT1t7HGJ6qLPZoOxwFJX0=; b=DKb9EMCX8Wi5FM8m4Bsdn/mxAv1cbCLE/1Q/F6hUtEvssXkb+GtLbarPzOkGGdX5WYOnik tlusV+pfZJZlBrAA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org Subject: [PATCH printk v5 07/40] um: kmsg_dump: only dump when no output console available Date: Wed, 16 Nov 2022 17:27:19 +0106 Message-Id: <20221116162152.193147-8-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 initial intention of the UML kmsg_dumper is to dump the kernel buffers to stdout if there is no console available to perform the regular crash output. However, if ttynull was registered as a console, no crash output was seen. Commit e23fe90dec28 ("um: kmsg_dumper: always dump when not tty console") tried to fix this by performing the kmsg_dump unless the stdio console was behind /dev/console or enabled. But this allowed kmsg dumping to occur even if other non-stdio consoles will output the crash output. Also, a console being the driver behind /dev/console has nothing to do with a crash scenario. Restore the initial intention by dumping the kernel buffers to stdout only if a non-ttynull console is registered and enabled. Also add detailed comments so that it is clear why these rules are applied. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- arch/um/kernel/kmsg_dump.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 0224fcb36e22..40abf1e9ccb1 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -17,13 +17,22 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, unsigned long flags; size_t len = 0; - /* only dump kmsg when no console is available */ + /* + * If no consoles are available to output crash information, dump + * the kmsg buffer to stdout. + */ + if (!console_trylock()) return; for_each_console(con) { - if(strcmp(con->name, "tty") == 0 && - (con->flags & (CON_ENABLED | CON_CONSDEV)) != 0) { + /* + * The ttynull console and disabled consoles are ignored + * since they cannot output. All other consoles are + * expected to output the crash information. + */ + if (strcmp(con->name, "ttynull") != 0 && + (con->flags & CON_ENABLED)) { break; } } -- 2.30.2