From patchwork Fri Feb 10 19:37:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9567379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9FB8560572 for ; Fri, 10 Feb 2017 19:39:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DFED285B8 for ; Fri, 10 Feb 2017 19:39:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 801C1285C1; Fri, 10 Feb 2017 19:39:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 8A543285B8 for ; Fri, 10 Feb 2017 19:39:19 +0000 (UTC) Received: (qmail 22009 invoked by uid 550); 10 Feb 2017 19:38:08 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 21800 invoked from network); 10 Feb 2017 19:38:05 -0000 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,142,1484035200"; d="scan'208";a="1093296265" From: william.c.roberts@intel.com To: linux-kernel@vger.kernel.org, joe@perches.com, apw@canonical.com Cc: keescook@chromium.org, kernel-hardening@lists.openwall.com, William Roberts Date: Fri, 10 Feb 2017 11:37:49 -0800 Message-Id: <1486755469-21573-1-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [kernel-hardening] [PATCH] checkpatch: add warning on %pk instead of %pK usage X-Virus-Scanned: ClamAV using ClamSMTP 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); Signed-off-by: William Roberts --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 982c52c..f20f5c5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6096,6 +6096,12 @@ sub process { "recursive locking is bad, do not use this ever.\n" . $herecurr); } +# check for bad %pK usage + if ($rawline =~ /\%pk/) { + WARN("FORMAT SPECIFIER", + "%pk is close to %pK, did you mean %pK?.\n" . $herecurr); + } + # check for lockdep_set_novalidate_class if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || $line =~ /__lockdep_no_validate__\s*\)/ ) {