From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbdBJWON convert rfc822-to-8bit (ORCPT ); Fri, 10 Feb 2017 17:14:13 -0500 Received: from mga01.intel.com ([192.55.52.88]:2391 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751452AbdBJWOJ (ORCPT ); Fri, 10 Feb 2017 17:14:09 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,142,1484035200"; d="scan'208";a="1124980864" From: "Roberts, William C" To: 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//+bwQA= Date: Fri, 10 Feb 2017 22:14:08 +0000 Message-ID: <476DC76E7D1DF2438D32BFADF679FC562305C559@ORSMSX103.amr.corp.intel.com> References: <1486755469-21573-1-git-send-email-william.c.roberts@intel.com> <1486757549.2192.20.camel@perches.com> In-Reply-To: <1486757549.2192.20.camel@perches.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.138] 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 > -----Original Message----- > From: Joe Perches [mailto:joe@perches.com] > Sent: Friday, February 10, 2017 12:12 PM > To: Roberts, William C ; linux- > kernel@vger.kernel.org; apw@canonical.com; Andew Morton foundation.org> > Cc: keescook@chromium.org; kernel-hardening@lists.openwall.com > Subject: Re: [PATCH] checkpatch: add warning on %pk instead of %pK usage > > 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/) { > + my $format = get_quoted_string($line, $rawline); > + if ($format =~ > /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGN]).)/) { > + WARN("VSPRINTF_POINTER_EXTENSION", > + "Invalid vsprintf pointer extension '$1'\n" . > $herecurr); > + } > + } > + > # check for logging continuations > if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) { > WARN("LOGGING_CONTINUATION",