Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp554080rwb; Mon, 26 Sep 2022 02:46:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65fLIZehw/ybw+T8EjqKCL9u7XWf/ZExsHBqYbUGZqp5NAtaE0GgCk3rnVjkwTRppdYo9k X-Received: by 2002:a63:d40b:0:b0:43b:e86f:d384 with SMTP id a11-20020a63d40b000000b0043be86fd384mr18987587pgh.167.1664185566407; Mon, 26 Sep 2022 02:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664185566; cv=none; d=google.com; s=arc-20160816; b=cRK0/ZZAJSvwXEVgYkt4QSZM6B1cjFvY7GM0/ti07wuxNuI4VZm64jHQR6jzix/CWx NqXK/cUzQYwNV7985xpEI47eHOjmqvM7RsFRmOTSLERa6s40WDJfhtSwWm4/NljO2sFN D3t1ub+xir2fHJDiswU5cb3fDMtrMWQ97x745WwRzwO4IW+aF6d3n0bgLx/VaDstLsoO ZhalZ0NfkjfWvv/xAyce0j4WA6GfnT02WxSP6jIO0kAeLe0NbGo6zfzVOEa51dWqog5R HksoLtvgJd6GgpwdV+xPMjuhtul+9pP+0E/m1QNnnqXv7j/DPGlh46gOJT5C4v4k3Wrj vifQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=H9yo7nQ7X6csLZdzPbIjxBnehSyTfz7orjW0yNtRxTE=; b=D8rQJ5aRu8ILHuP73W5DbtcfW3qmGsJWz9qA+ElFoV44Fq9h+FgTG4M3tx7Z/Tx8Le nGfe/UpwwBbnpal/px7JV3oVUiCp6FtKggSd63cnOMQ8Jo4Aw0Trt9yp1VoXIzZi6dSr /GAgST4SFJuHZA2vlB1MHpPl7ulRxqqPPVS+xCms/7rOwCMptZjiyVjm7seEHgvUS8Rl jQoPbV/TCgg7XfIuVBhKkzIF3upb+IiO8h2R1Yy4Mvt7AF+Sy/B+f9atvjaR2z6zPLnq m8y3zksm44HDR95x0EoNAbNz3HWqDfVdcepk5ApR2Yh4Add3GlsKarNL+apHHlx+Zn0S yunQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bKhWn1gW; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a056a00191100b005588e638fb9si218697pfi.381.2022.09.26.02.45.54; Mon, 26 Sep 2022 02:46:06 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=bKhWn1gW; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbiIZJeM (ORCPT + 99 others); Mon, 26 Sep 2022 05:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235054AbiIZJdo (ORCPT ); Mon, 26 Sep 2022 05:33:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A9F326C2 for ; Mon, 26 Sep 2022 02:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664184820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H9yo7nQ7X6csLZdzPbIjxBnehSyTfz7orjW0yNtRxTE=; b=bKhWn1gWvhj7Bh7ttKpKwKlqOFN66DmQSbPvWvu0bsF545aV78flz5bDrHJDoi4BXwo8uP ec27cMPuwWRK22Kdt+zjkofKZCGrPNVaDRdx7Akwcf9R/Gj2G3OaAME7WbZxbf8dCQRhOE 92QbhWn/feB3srhZJwuLNkKdaH3cnTg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-1-s3APgJMlNz24koPu5jpTqw-1; Mon, 26 Sep 2022 05:33:39 -0400 X-MC-Unique: s3APgJMlNz24koPu5jpTqw-1 Received: by mail-wr1-f71.google.com with SMTP id i27-20020adfaadb000000b0022a48b6436dso975300wrc.23 for ; Mon, 26 Sep 2022 02:33:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=H9yo7nQ7X6csLZdzPbIjxBnehSyTfz7orjW0yNtRxTE=; b=kmnA7KLVEk55HLuUoRe3b3ErSZUgZ57k72rV7dFg3GZDgDbUuYFDg23B6+kApqGOmT IVsbrcnaHoL186F5P+CW7NLvA7EHJ69kDvpnQQAlKnpt3NxVWsF+/VjDopODD7hFFV9r vLHtzEMQcby2EiZtivy2Q5adV2QDnxJ0rLg/+9GHX+y+BOoqgz7/8Gly4LDwSNpYT+p9 5B5tstvXRfRNT1U7Yk+SVly5omhGTOaHFAT8i+MSDb1JLEe4jay7hzILIh0iOkE28eso DdwkD0j5T6WaXO2qpOe8+es4czvftClo7St+H2OUCsqTSF4bCmL+WuX/o5Tn3CE8AuJi Tz2w== X-Gm-Message-State: ACrzQf1SNXId/fdypwwosJVu5YIuBjR3b30bqHhmJyC9OFgD9gNXXeEa clMyvSfkC04Y4985tbwVCRC+1rxLHGF9Xxi8MB5BnuVIWr4Gc/BzCWecOHPyHdRQWGMhixJam4B vdpsxMHyk5hzh+gDJrZXQmAo= X-Received: by 2002:a05:600c:114f:b0:3b4:9a0a:6204 with SMTP id z15-20020a05600c114f00b003b49a0a6204mr14264178wmz.132.1664184818143; Mon, 26 Sep 2022 02:33:38 -0700 (PDT) X-Received: by 2002:a05:600c:114f:b0:3b4:9a0a:6204 with SMTP id z15-20020a05600c114f00b003b49a0a6204mr14264155wmz.132.1664184817894; Mon, 26 Sep 2022 02:33:37 -0700 (PDT) Received: from localhost (cpc111743-lutn13-2-0-cust979.9-3.cable.virginm.net. [82.17.115.212]) by smtp.gmail.com with ESMTPSA id n32-20020a05600c502000b003a531c7aa66sm10720950wmr.1.2022.09.26.02.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 02:33:36 -0700 (PDT) Date: Mon, 26 Sep 2022 10:33:35 +0100 From: Aaron Tomlin To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , Luis Chamberlain , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: Re: [PATCH printk 10/18] kgbd: Pretend that console list walk is safe Message-ID: <20220926093335.exvrpwp5khlwqxhp@ava.usersys.com> X-PGP-Key: http://pgp.mit.edu/pks/lookup?search=atomlin%40redhat.com X-PGP-Fingerprint: 7906 84EB FA8A 9638 8D1E 6E9B E2DE 9658 19CC 77D6 References: <20220924000454.3319186-1-john.ogness@linutronix.de> <20220924000454.3319186-11-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220924000454.3319186-11-john.ogness@linutronix.de> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 On Sat 2022-09-24 02:10 +0206, John Ogness wrote: > From: Thomas Gleixner > > Provide a special list iterator macro for KGDB to allow unprotected list > walks and add a few comments to explain the hope based approach. > > Preperatory change for changing the console list to hlist and adding > lockdep asserts to regular list walks. > > Signed-off-by: Thomas Gleixner > Signed-off-by: John Ogness > Reviewed-by: Sergey Senozhatsky > --- > drivers/tty/serial/kgdboc.c | 5 ++++- > include/linux/console.h | 10 ++++++++++ > kernel/debug/kdb/kdb_io.c | 7 ++++++- > 3 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c > index af2aa76bae15..57a5fd27dffe 100644 > --- a/drivers/tty/serial/kgdboc.c > +++ b/drivers/tty/serial/kgdboc.c > @@ -462,10 +462,13 @@ static void kgdboc_earlycon_pre_exp_handler(void) > * we have no other choice so we keep using it. Since not all > * serial drivers might be OK with this, print a warning once per > * boot if we detect this case. > + * > + * Pretend that walking the console list is safe... > */ > - for_each_console(con) > + for_each_console_kgdb(con) { > if (con == kgdboc_earlycon_io_ops.cons) > return; > + } > > already_warned = true; > pr_warn("kgdboc_earlycon is still using bootconsole\n"); > diff --git a/include/linux/console.h b/include/linux/console.h > index 24344f9b0bc1..86a6125512b9 100644 > --- a/include/linux/console.h > +++ b/include/linux/console.h > @@ -187,6 +187,16 @@ extern void console_list_unlock(void) __releases(console_mutex); > #define for_each_console(con) \ > for (con = console_drivers; con != NULL; con = con->next) > > +/** > + * for_each_console_kgdb() - Iterator over registered consoles for KGDB > + * @con: struct console pointer used as loop cursor > + * > + * Has no serialization requirements and KGDB pretends that this is safe. > + * Don't use outside of the KGDB fairy tale land! > + */ > +#define for_each_console_kgdb(con) \ > + for (con = console_drivers; con != NULL; con = con->next) > + > extern int console_set_on_cmdline; > extern struct console *early_console; > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 67d3c48a1522..fb3775e61a3b 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -558,7 +558,12 @@ static void kdb_msg_write(const char *msg, int msg_len) > cp++; > } > > - for_each_console(c) { > + /* > + * This is a completely unprotected list walk designed by the > + * wishful thinking department. See the oops_in_progress comment > + * below - especially the encourage section... > + */ > + for_each_console_kgdb(c) { > if (!(c->flags & CON_ENABLED)) > continue; > if (c == dbg_io_ops->cons) > -- > 2.30.2 > Reviewed-by: Aaron Tomlin -- Aaron Tomlin