Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4285876ybl; Tue, 20 Aug 2019 09:35:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdI+jU475LMA4Aolj9IZqGFxP6izr9Ke8ZdmOPiV7yN4vbdyBwqK4mFwdKq2ILtIiTl0Ut X-Received: by 2002:a17:902:b094:: with SMTP id p20mr8884300plr.320.1566318950212; Tue, 20 Aug 2019 09:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566318950; cv=none; d=google.com; s=arc-20160816; b=CI5M2t3XfLyUSjSz07rhIcrHB7KiFm97k+ixD2SzmywuzfQd+DFZDKUQgCBQck9Rdb MKhMA8O6nO4Wb24/+OsiN5gVdXJz6q8hXvdJ35gx1DYmfNETMoF6nmoYjdFhXhoF3EZh subFgv804eqyMP82c+0PzoiK1Z596iNFaq6BIRx5Xg55K0jrDnRY02nF0zfZMHZLMtHv 7uBoGWsodU7iYb9tAUhSy5ffo00mhtruFtv2F0MGrx+lLT4hmc1DvPDYILpCp6bjF8FE /kKN0seF1OAt0TwqkJnky997HjaJt/0W0MyqCeuFE+lUICkvNF+2rFhDgw68jYOIxAIZ 2ABg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sA90vJz/rbgCroFZTlA5Yw1nyMDsyVq6b6DiHDXrFY0=; b=PRbw76DaaCC0i8Uosq2/it8aydBUfkI0umPe7wV3SwI6teTWAJj34WIGBl5vfZDFM9 zIe5wyTBKR0bXD19RDRKN+1t35Eaeo6j1nUaLN7E8SezhAkeHpPAwRdezFEu0NJ9kwsm zOhGlGKfeCd2QJgwEdAI9MsgoMLl9gX7fBfxrGWJNh0vmJI75axmFhazACfC9X3JpGsU uDp1dXOMG0ylN/Rss1yHlIKEVVelA4WzY3XICOHjwoB9noyEHuRUQ6FFwgcQiovNO7Z8 JM8wbFyyYvKLoSamAUhEjKDFoCxfJNxprNQFqI4B0datftsKOsyjzHK+SzcqvFk4qOBw 1zvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cYzXk3Dw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q26si13322788pfh.286.2019.08.20.09.35.33; Tue, 20 Aug 2019 09:35:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cYzXk3Dw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730154AbfHTQd1 (ORCPT + 99 others); Tue, 20 Aug 2019 12:33:27 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45431 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbfHTQd1 (ORCPT ); Tue, 20 Aug 2019 12:33:27 -0400 Received: by mail-pl1-f195.google.com with SMTP id y8so3020585plr.12 for ; Tue, 20 Aug 2019 09:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=sA90vJz/rbgCroFZTlA5Yw1nyMDsyVq6b6DiHDXrFY0=; b=cYzXk3DwZRgs8EAm1g3fVOu+Z4tn7HOv+jpf9QjbsWzX4NXP/Z29Kf/EIhyFPgdmft Si0gk/LKQoYihhNVviMseqNHT7bZIno7OfUiaUQT8FNXEofq/Hb8qW2iYXeJRTGao4nM GzveFF2KwG+Ju5sJ4Qx1kUpEovl+vjfCLefZk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=sA90vJz/rbgCroFZTlA5Yw1nyMDsyVq6b6DiHDXrFY0=; b=HoF0QoY8gz4SqXU1HtOHgNoyeFD5JFZXtrUjnacD4SyxC2pKuot+yZ0b8gHBI+EGFg v26i26IgvWG8ABlv34dnuypLelORhgzvGlTdZkz8bXU5B2CfiCvlwK2gu/D6EHxQGuVR SE1xoo2OP+V/kY1qN/SdMAx9hI2zgvozZEmcOcf2d8GKzBVMDrjRpu+C6M+M+qNPnGNW 5o5+cyYecoZwcBSRigZYkVBz/tQbgQaSiHwMZvVhd0+LYM/D4cvvb/+ybiN8insSgW0m aQ1RVBg6uB2pAAcUZ41A60RhA9mn/+k+q7q06pR73JFr+ujtm6mecTeGeK1y6wpeA9p7 qDvQ== X-Gm-Message-State: APjAAAWwWscnCehraPF0729zUdP/mJH3q45RC9KcaaRstXNrz7jyyr70 Ximlu6oHbSpVptoYD5GPh2ZCGg== X-Received: by 2002:a17:902:8d95:: with SMTP id v21mr29689291plo.267.1566318807022; Tue, 20 Aug 2019 09:33:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 33sm17723932pgy.22.2019.08.20.09.33.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 09:33:26 -0700 (PDT) Date: Tue, 20 Aug 2019 09:33:24 -0700 From: Kees Cook To: Christophe Leroy Cc: Peter Zijlstra , Andrew Morton , Drew Davenport , Arnd Bergmann , "Steven Rostedt (VMware)" , Feng Tang , Petr Mladek , Mauro Carvalho Chehab , Borislav Petkov , YueHaibing , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 7/7] bug: Move WARN_ON() "cut here" into exception handler Message-ID: <201908200908.6437DF5@keescook> References: <20190819234111.9019-1-keescook@chromium.org> <20190819234111.9019-8-keescook@chromium.org> <20190820100638.GK2332@hirez.programming.kicks-ass.net> <06ba33fd-27cc-3816-1cdf-70616b1782dd@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <06ba33fd-27cc-3816-1cdf-70616b1782dd@c-s.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 20, 2019 at 12:58:49PM +0200, Christophe Leroy wrote: > Le 20/08/2019 ? 12:06, Peter Zijlstra a ?crit?: > > On Mon, Aug 19, 2019 at 04:41:11PM -0700, Kees Cook wrote: > > > > > diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h > > > index 588dd59a5b72..da471fcc5487 100644 > > > --- a/include/asm-generic/bug.h > > > +++ b/include/asm-generic/bug.h > > > @@ -10,6 +10,7 @@ > > > #define BUGFLAG_WARNING (1 << 0) > > > #define BUGFLAG_ONCE (1 << 1) > > > #define BUGFLAG_DONE (1 << 2) > > > +#define BUGFLAG_PRINTK (1 << 3) > > > #define BUGFLAG_TAINT(taint) ((taint) << 8) > > > #define BUG_GET_TAINT(bug) ((bug)->flags >> 8) > > > #endif > > > > > diff --git a/lib/bug.c b/lib/bug.c > > > index 1077366f496b..6c22e8a6f9de 100644 > > > --- a/lib/bug.c > > > +++ b/lib/bug.c > > > @@ -181,6 +181,15 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) > > > } > > > } > > > + /* > > > + * BUG() and WARN_ON() families don't print a custom debug message > > > + * before triggering the exception handler, so we must add the > > > + * "cut here" line now. WARN() issues its own "cut here" before the > > > + * extra debugging message it writes before triggering the handler. > > > + */ > > > + if ((bug->flags & BUGFLAG_PRINTK) == 0) > > > + printk(KERN_DEFAULT CUT_HERE); > > > > I'm not loving that BUGFLAG_PRINTK name, BUGFLAG_CUT_HERE makes more > > sense to me. That's fine -- easy rename. :) > Actually it would be BUGFLAG_NO_CUT_HERE then, otherwise all arches not > using the generic macros will have to add the flag to get the "cut here" > line. I am testing for the lack of the flag (so that only the CONFIG_GENERIC_BUG with __WARN_FLAGS case needs to set it). I was thinking of the flag to mean "this reporting flow has already issued cut-here". It sounds like it would be more logical to have it named BUGFLAG_NO_CUT_HERE to mean "do not issue a cut-here; it has already happened"? I will update the patch. Thanks! -- Kees Cook