From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbdBJW0h convert rfc822-to-8bit (ORCPT ); Fri, 10 Feb 2017 17:26:37 -0500 Received: from mga07.intel.com ([134.134.136.100]:58318 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751081AbdBJW0g (ORCPT ); Fri, 10 Feb 2017 17:26:36 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,142,1484035200"; d="scan'208";a="1093345304" From: "Roberts, William C" To: "Roberts, William C" , Joe Perches , "linux-kernel@vger.kernel.org" , "apw@canonical.com" , Andew Morton CC: "keescook@chromium.org" , "kernel-hardening@lists.openwall.com" Subject: RE: [PATCH] checkpatch: add warning on %pk instead of %pK usage Thread-Topic: [PATCH] checkpatch: add warning on %pk instead of %pK usage Thread-Index: AQHSg9UvWAPxVS9whUiJ3t5Bad2kYaFjMnOA//+bwQCAAAERAA== Date: Fri, 10 Feb 2017 22:26:34 +0000 Message-ID: <476DC76E7D1DF2438D32BFADF679FC562305C5BA@ORSMSX103.amr.corp.intel.com> References: <1486755469-21573-1-git-send-email-william.c.roberts@intel.com> <1486757549.2192.20.camel@perches.com> <476DC76E7D1DF2438D32BFADF679FC562305C559@ORSMSX103.amr.corp.intel.com> In-Reply-To: <476DC76E7D1DF2438D32BFADF679FC562305C559@ORSMSX103.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDBkNDgxN2YtYTFmMS00NDg0LWJkZTAtZTIyM2I1ZTM2ZTEzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Im05Tm9oTGNMS216RHB6XC9hTDdCQk1XRkJKSGVtTHMreW5MaCs1Z1RUT0hRPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.22.254.140] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > On Fri, 2017-02-10 at 11:37 -0800, william.c.roberts@intel.com wrote: > > > From: William Roberts > > > > > > Sample output: > > > WARNING: %pk is close to %pK, did you mean %pK?. > > > \#20: FILE: drivers/char/applicom.c:230: > > > + printk(KERN_INFO "Could not allocate IRQ %d for PCI > > Applicom > > > +device. %pk\n", dev->irq, pci_get_class); > > > > There isn't a single instance of this in the kernel tree. > > > > Maybe if this is really useful, then all the %p extensions should > > be enumerated and all unknown uses should have warnings. > > I was thinking of doing that, but I figured I would start with the bare minimum > patch. > > > > > Something like: > > > > --- > > scripts/checkpatch.pl | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index > > ad5ea5c545b2..8a90b457e8b5 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -5305,6 +5305,15 @@ sub process { > > } > > } > > > > +# check for vsprintf extension %p misuses > > + if ($line =~ /\b$logFunctions\s*\(.*$String/) { I don't see the normal string formatting routines in that list... I think this is too restrictive. > > + my $format = get_quoted_string($line, $rawline); Ahh thanks for that get_quoted_string(). > > + if ($format =~ > > /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGN]).)/) { > > + WARN("VSPRINTF_POINTER_EXTENSION", > > + "Invalid vsprintf pointer extension '$1'\n" . > > $herecurr); I think I'll send out a V2 with this part of the addition. I like that, and your wording. > > + } > > + } > > + > > # check for logging continuations > > if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) { > > WARN("LOGGING_CONTINUATION", I did a grep on some of the patters to see what it would match against