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 <william.c.roberts@intel.com>
Subject: [PATCH v3] checkpatch: add warning on invalid %p extensions
Date: Fri, 10 Feb 2017 15:49:56 -0800 [thread overview]
Message-ID: <1486770596-15526-1-git-send-email-william.c.roberts@intel.com> (raw)
From: William Roberts <william.c.roberts@intel.com>
The kernel supports %p extensions as documented in
Documentation/printk-formats.txt. Warn on possibly
improper use of non-extension characters.
One issue would be the usage of %pk when %pK should have
been used. This has a side-effect of appearing to work
alright, but does not respect the kptr_restrict setting
as %pK does.
Sample output:
WARNING: Invalid vsprintf pointer extension '%pk'
+ printk(KERN_INFO "Could not allocate IRQ %d for PCI Applicom device. %pk\n", dev->irq, pci_get_class); // NOT OK
improved-by: joe@perches.com
Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
scripts/checkpatch.pl | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 982c52c..dfc1c11 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6096,6 +6096,15 @@ sub process {
"recursive locking is bad, do not use this ever.\n" . $herecurr);
}
+ # check for vsprintf extension %p<foo> 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 lockdep_set_novalidate_class
if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
$line =~ /__lockdep_no_validate__\s*\)/ ) {
--
2.7.4
reply other threads:[~2017-02-10 23:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486770596-15526-1-git-send-email-william.c.roberts@intel.com \
--to=william.c.roberts@intel.com \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®