Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1854008rwb; Mon, 7 Nov 2022 06:34:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM6EkAUdxsS3tQeaee/PKjq7x1bvzb4D7pM+WqkF71NANowghIUbiUvvnv3GqAdQaYgsogqi X-Received: by 2002:a17:906:8b81:b0:7ad:93d1:5eae with SMTP id nr1-20020a1709068b8100b007ad93d15eaemr50288660ejc.29.1667831686372; Mon, 07 Nov 2022 06:34:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667831686; cv=none; d=google.com; s=arc-20160816; b=ZdEfoa2sfwYsLY0nY+SVZD1xhnLrTtEF0/HNSBlHJ0l/s+mD7gIs3qWYjkycFzuKst pHQyiqq/uYDYQ59AS46bYFn7pdhv/PYizpUI5EYFsa+ck7wkCgT0ew9eXx1DQ2pb/BeR aYBe5mSc5YCiulIp2WpSbYl1NBjsqcSX0oQSYpxRuHlB4qAIboKJg5saI6V/cBfWMPVU dByP5UgpvkGHWIiI3d4LqvvnLBVfsGnVTm/g7TW5H/cdNED2BinYBpl/v4PtVMTWH8VT wRrkxm9oSFscAqr/UdCoIFEt683x04BzNlY7zdAa0H/bFK6QfTD24tPUtXYFihkGA00U dz4w== 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=UHuP0rbZWQQBzSmPTErQb30w1r8OemTOVXxBtKXD5zo=; b=Oc2rte8oPxAAeHamxH0ZZxTOCML1t+SL/Lf8XXKuEjBqYCTWoGMgic4rvJG28wFkcD jIKdwnqG5LAcakUjN21h5HzlF2PtwlJObYKAuOb73SEb86u+x2Oq98adjbcwiSttxm/w nYw5djve48MoGLOfSu6ux1u8lN+C+z/rv+h4OkImHc4I40PyQ9LlC12lyNnbZgnLR/F8 oMUflovt+AwtIZSUe3UOduYqCtnWPiScVqlCVZUDxeT4meQoiplzBeTb+VJZB2bEiA3m 0SYgsoVb4/1gdp8Oy5HI+PLErqBtj6H+WTtH7HjZdqUwaUnRb/AtlaCRO7aIK2Exnazh EgJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iNt4WLyb; dkim=neutral (no key) header.i=@linutronix.de; 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 ss28-20020a170907c01c00b0078d4a0c77f9si7477515ejc.458.2022.11.07.06.34.18; Mon, 07 Nov 2022 06:34:46 -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=iNt4WLyb; dkim=neutral (no key) header.i=@linutronix.de; 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 S232106AbiKGOR1 (ORCPT + 94 others); Mon, 7 Nov 2022 09:17:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbiKGOQs (ORCPT ); Mon, 7 Nov 2022 09:16:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E011D0ED; Mon, 7 Nov 2022 06:16:47 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830606; 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=UHuP0rbZWQQBzSmPTErQb30w1r8OemTOVXxBtKXD5zo=; b=iNt4WLybeNZ2mg/QU8nQRgYO3eRwjEe4TxpxeuViKZgOFqSLGdnxpB4EIHsbH38cw2h6Am kJVDUMhcmDfKwlcQItq60yXQiAM46j6B9Q30Uv+BDFud70sS99pVRWZsqjhTRdLZ1dBaFE UfhdVUIkj1KudfH6d1vG5YHIMtg+leLFlBPIIrj+Gzw03dt7+TXN3UcBPcTVmJ5kf31YVr G7mFekiqU9lb9lIMsaNunxvcSejZoGuF85W8nc+Rx/+O+XVwv+c9/Iu0yNjb2pkjvKZEFG FDPXkYTRkDp2Ifzzr8b9XUdgb2olC4aoS/elsnnplXFO8y8GhZMrmHrHM2DqiA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830606; 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=UHuP0rbZWQQBzSmPTErQb30w1r8OemTOVXxBtKXD5zo=; b=vWTVUpf3xvuqVwTe/KNxkvP7t8I4roXjMftkB13FmomVHEj3IjzCEpCFORfE4FT8CtCEsX KCLNz75VQR2R8iBg== 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 v3 12/40] tty: serial: kgdboc: document console_lock usage Date: Mon, 7 Nov 2022 15:22:10 +0106 Message-Id: <20221107141638.3790965-13-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-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 --- 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