Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp864383rwb; Wed, 16 Nov 2022 08:37:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Baydc2gK15llUImEgVrTUAeD24NNWPPy7sLFn4byBfznzXctYfTxBoc9OTAwjM9VcPmtl X-Received: by 2002:a63:e05:0:b0:439:753f:c81f with SMTP id d5-20020a630e05000000b00439753fc81fmr21815505pgl.51.1668616652765; Wed, 16 Nov 2022 08:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668616652; cv=none; d=google.com; s=arc-20160816; b=PaKkVpsCWkH2dfR4WxR2eH7sjQc0zTCHGmqDntfOrE8lONccc0bDS/5ZSOfT69U05r m2v2zVa5V0oo52SyiMX64eJD2BV0tApfE/veoPJ2GRuVKdqwo6/3Muo6p2C7HZM1th1Q vxDehTTGlSIBtrC7SWe6/lhcACzJR+Y03WNNa/KyLJHz6h10EIQHKldOr8N6z9welLQ5 6DVaR0RSGwQxnoAtn2GW/rjiMOzFlWkmeJhbWu0Q7dzslFxxMdnNw/ZQ4taEFi/eIc1K TYlQ/yJERorNiKVYbnw1SXxOfDb0R/pHf5ztG6LqLx29xw44q2pMHTvh4o3CVaymgTPz EcMQ== 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=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=jKUuN47lB3TgbSmijr4TrLw280L2BSFKMVHdfdo82bptMg17HZuIhF8bVSfhtwgY4f AGsfW0cfuRAb5a45+PuiGma1ewrGLW14H5QrSVm7/K5IFuDQTU8qg+3u+nkB5W8LlNjD 8ftjYBL/YEYAu5k4Q+aYRooJrq1U0yQEQq6TRtRS5JW4j7ig8SgIAYgbEesXXv31h5eK R6BVanIvasXecpwJ2/+iargUqq20qpd3NuDUsLS+Rt5rVTGJbtUiIarsA/9cByIb7Dda hA00/hi7U96rDubETG1YEj465YiwjqXtMY7vyKkL7skOwputO+oTXqRemzc62piSlH3f /fqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CEddAbi3; dkim=neutral (no key) header.i=@linutronix.de header.b=wWUGVs3m; 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 pc16-20020a17090b3b9000b0021332d10601si2583657pjb.183.2022.11.16.08.37.21; Wed, 16 Nov 2022 08:37:32 -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=CEddAbi3; dkim=neutral (no key) header.i=@linutronix.de header.b=wWUGVs3m; 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 S234908AbiKPQWl (ORCPT + 91 others); Wed, 16 Nov 2022 11:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbiKPQWE (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 60F56326F5; 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=1668615721; 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=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=CEddAbi3RzraEuQWrV50K39HBCaBs5n1hbnWKQvKdxtvYvNn7qth0mD3hPQU/k5IM6/6jI tsakH1BSYxyMEWSQ+SYJ0ZbSLVzyVLLN6/OuY208TtKzgXC6M7StlhGoOqITVvqEeeSE2M X8Is4GU+dlc+eKJOSLahx8apQ/7CBFU4io8nbjAZNv2xNFB/IGOy7i8ahbNIx2TlwkTdyz ibPl1VaO0F9fOd8M9cClH3/bgDQIBr7zIZlGTmpNxRMFTCwefsc+Ksw5eBzns2iBBhnSdp K1UNeEN6Iqb9zCaC3+k2B4ePn7UMXh2KRldr715r7YqNpg/80ijcaDxMTepW6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615721; 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=OX8P8PjcP3et+B8RxGuAu/qJSUE13puFYmEXVzvc8MY=; b=wWUGVs3m5zf238cl2T7E7PtRK7QDcJHWNVj1NK/JvMgbbu2/yMeyvExDpCJ6+ELC+PGYAH BBDa/hEaxQ3F/JAw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v5 08/40] tty: serial: kgdboc: document console_lock usage Date: Wed, 16 Nov 2022 17:27:20 +0106 Message-Id: <20221116162152.193147-9-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 kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. This is necessary because the trapping of the exit() callback assumes that the exit() callback is not called before the trap is setup. Explicitly document this non-typical console_lock usage. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Douglas Anderson Reviewed-by: Daniel Thompson Reviewed-by: Petr Mladek --- drivers/tty/serial/kgdboc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index e76f0186c335..5be381003e58 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -530,6 +530,14 @@ static int __init kgdboc_earlycon_init(char *opt) * Look for a matching console, or if the name was left blank just * pick the first one we find. */ + + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until the kgdboc_earlycon setup is complete. + * Trapping the exit() callback relies on exit() not being + * called until the trap is setup. This also allows safe + * traversal of the console list and race-free reading of @flags. + */ console_lock(); for_each_console(con) { if (con->write && con->read && -- 2.30.2