From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932346AbcHOUjp (ORCPT ); Mon, 15 Aug 2016 16:39:45 -0400 Received: from smtprelay0200.hostedemail.com ([216.40.44.200]:50880 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932115AbcHOUjo (ORCPT ); Mon, 15 Aug 2016 16:39:44 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::,RULES_HIT:41:355:379:541:599:800:960:967:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2525:2553:2560:2563:2682:2685:2828:2859:2899:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:6691:7903:8660:9025:9108:10004:10400:10848:11026:11232:11473:11658:11783:11914:12043:12296:12517:12519:12663:12740:13148:13230:13439:13894:14181:14659:14721:21067:21080:21220:21451:30012:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:7,LUA_SUMMARY:none X-HE-Tag: bun53_54a530eff4719 X-Filterd-Recvd-Size: 3044 Message-ID: <1471293580.4075.111.camel@perches.com> Subject: Re: BUG and WARN kernel log levels From: Joe Perches To: Kees Cook Cc: LKML Date: Mon, 15 Aug 2016 13:39:40 -0700 In-Reply-To: References: <1471287614.4075.85.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2016-08-15 at 13:28 -0700, Kees Cook wrote: > On Mon, Aug 15, 2016 at 12:00 PM, Joe Perches wrote: > > On Mon, 2016-08-15 at 11:53 -0700, Kees Cook wrote: > > > So, I noticed that asm-gemeric/bug.h defines BUG() without a log level: > > > > > > #ifndef HAVE_ARCH_BUG > > > #define BUG() do { \ > > >        printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ > > > > > > Seems like it should have one? > > > > > > Also, I think we might want to examine WARN() a bit... it doesn't have > > > a log level either, but only a fraction of callers set one: > > > > > > $ git grep -E 'WARN(_TAINT|)(_RATELIMIT|_ONCE|)\([^\)]' | grep -v KERN_ | wc -l > > > 2735 > > > > > > $ git grep -E 'WARN(_TAINT|)(_RATELIMIT|_ONCE|)\([^\)]' | grep KERN_ | wc -l > > > 77 > > > > > > If I'm reading checkpatch.pl correctly, it doesn't warn about missing > > > log levels on WARN calls, but I think it should. > > > > > > How do you think is best to clean this up? > > > > > > Mainly, I'd like to add a format string to BUG, or introduce a new > > > BUGish call that takes a format... > > I once suggested something similar awhile ago. > > https://lkml.org/lkml/2008/7/8/261 > > > > I think it's best to remove any KERN_ from the use of > > all the WARN variants and add it to the WARN definitions. > Yeah, that's what I was thinking too. It does mean that the format > needs to be a const char string, though. No it doesn't mean that. Prefixing KERN_WARNING to the const char[] types and using KERN_WARNING "%pV" could work for the non const char[] types Or maybe use the same KERN_WARNING "%pV" for simpler code. > > Same with BUG. > Yeah, though for full effect, it needs to be plumbed into each > architecture's BUG handler. Mainly what I don't like is that if I do > this on x86: > > pr_err("eek, terrible thing\n"); > BUG(); > > I get a dmesg that read: > > eek, terrible thing > === cut here === > ...traceback, etc > > I'd like the "eek" part to be inside the "cut here". And I'd like BUGs > to be able to be more verbose. Maybe add BUG_MSG/BUG_ON_MSG or some such.