Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5748357rwb; Mon, 14 Nov 2022 08:57:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fhBCs1U3aUvQdSUv9IKZm5Ac7LDLCu5pKS5v5D/1oCwAiRXqjL/wF4WBw+9/jIUdIBJlA X-Received: by 2002:a05:6402:519:b0:467:6847:1ea7 with SMTP id m25-20020a056402051900b0046768471ea7mr10908521edv.237.1668445038971; Mon, 14 Nov 2022 08:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668445038; cv=none; d=google.com; s=arc-20160816; b=AoQZPM+X0LLVGT7OdQUeJ52Wxe45U3WP9bWdgFTe0iK8Wj/mVlH046VlFMPo6TB2up LR160AJblvPNX4A7lpOMsj5SjNTbM2psoYJHi0x/UNK2JOiw212g33FYec5U/GaxzP+Q DIpk5Cfm26MZrqpKvSa4bha+JS4zi+3v4geoSKI3uc382XgMNEiaEaGTkxudq6knjuJu HBU+PZoU53/JNO8GTsMZ9TNee5qGk0koy/J0DGyn+Rj0RR+nKj1SHMf48difNtkOykzj 08EkD/D9kqYmashB5Jp/pTGjRZfAqxpvq5R90u4EeCclCE0n1anYfw+ZEcGj8AoQ2L/k wGNw== 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=LeM6Jg4jDT+XoXiE8HEnVW0X8xGOduvTHNcubWb/a90HEYdfs+jK45PPnyHAPrOeIW /6r5862qMTWiey92Nn++ZQ/qAYi9hPCVU+PKN28RPTMvfSsA+Tai/h90XIf2fSZjKATp Qzvpo0R90bMVfJCe7d/u3K/43P0PoMprqz1X8gwbCRt77PgGegL31LMvMZ+7WDbbnygI N8mh7CjZ4uUlmRLlmUx93tuGSIIYm5UGJnUpG923nB0MLY9Hgqx3nMHkQ3Hiuq+RoRPN mGWdorNcahSmpiqEWVbdqIAbxFjQkoLCGpI0SPuhTy17HRFKzXZA/hpZ0+f9gzkpZri4 Edrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="07f/Iv1w"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tELjjwZ8; 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 ho11-20020a1709070e8b00b007ae29da29e4si9606083ejc.962.2022.11.14.08.56.57; Mon, 14 Nov 2022 08:57:18 -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="07f/Iv1w"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tELjjwZ8; 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 S237595AbiKNQaF (ORCPT + 87 others); Mon, 14 Nov 2022 11:30:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237531AbiKNQ3k (ORCPT ); Mon, 14 Nov 2022 11:29:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964EB102C; Mon, 14 Nov 2022 08:29:39 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443377; 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=07f/Iv1wL9DpAMhdAgc7Xt3WxoplT/3Nu02eKR1b8+j1+Y7qfzi1+FNR+cnpkz+yvo16Ze MBTxlfIFPnOpIaZmaWz8PKDgW1EEFLce5Z7cjkdy6Vz0eKot3ypTtDpD7aXfrOfrZ5b4jX QntAcdes7YddyPfeX5F8PQ8xBH1C/Xmv0UymHEQmXC9tX8u9cMQ0818P0ky0qz/V24Ia2u 6PtsU3Op8WIIueIM9CeNFqHhD5rmh6U9hltEKu6vOewN2wBbCliUb2DS6q5csf2Eu5FEkm eEGxJwFLBff19l0CYvNQu8UBltdyze2FqKOkIC9D+rP9sBHRrdRV24X32/Thow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443377; 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=tELjjwZ800XS5coQk0qRU9bwQBSC526T8kNf1rYyslpyZ3bvfpKU2a+6OVmFy+qzAW3ZUV +iS9PnHyufG1tIDg== 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 v4 07/39] tty: serial: kgdboc: document console_lock usage Date: Mon, 14 Nov 2022 17:35:00 +0106 Message-Id: <20221114162932.141883-8-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-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