From: Palmer Dabbelt <palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>
To: arnd-r2nGTMty4D4@public.gmane.org
Cc: 3chas3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org
Cc: mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org
Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-atm-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org
Cc: tomi.valkeinen-l0cyMroinI0@public.gmane.org
Cc: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: Palmer Dabbelt <palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl
Date: Wed, 9 Sep 2015 14:08:22 -0700 [thread overview]
Message-ID: <1441832902-28993-14-git-send-email-palmer@dabbelt.com> (raw)
In-Reply-To: <1441832902-28993-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>
I recently got bit by a CONFIG_ in userspace bug. This has apparently
happened before, but the check got disabled for triggering too much.
In order to reduce false positives, I added some hueristics to avoid
detecting comments.
Since these tests all pass, I've now re-enabled them.
Signed-off-by: Palmer Dabbelt <palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Andrew Waterman <waterman-aFE07iDfcCIb0cFwG/AQJIdd74u8MsAO@public.gmane.org>
Reviewed-by: Albert Ou <aou-aFE07iDfcCIb0cFwG/AQJIdd74u8MsAO@public.gmane.org>
---
| 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
--git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 62320f93e903..dd413ad9c850 100755
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -40,7 +40,7 @@ foreach my $file (@files) {
&check_asm_types();
&check_sizetypes();
&check_declarations();
- # Dropped for now. Too much noise &check_config();
+ &check_config();
}
close $fh;
}
@@ -76,9 +76,24 @@ sub check_declarations
}
}
+my $check_config_in_multiline_comment = 0;
sub check_config
{
- if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+ my $nocomments = $line;
+ $nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+ $nocomments =~ s/\/\/.*//; # Remove C99-style comments (// to EOL)
+
+ # Check to see if we're within a multiline comment, and if so
+ # just remove the whole line. I tried matching on '^ * ', but
+ # there's one header that doesn't prepend multi-line comments
+ # with * so that won't work.
+ if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+ if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+ if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+ # Check to see if there is something that looks like CONFIG_
+ # inside a userspace-accessible header file and if so, print that out.
+ if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
}
}
--
2.4.6
next prev parent reply other threads:[~2015-09-09 21:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2644177.lVCYzIBfPW@wuerfel>
2015-09-09 21:08 ` [PATCH] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 01/13] " Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 03/13] Hide COMPAT_ATM_ADDPARTY behind #ifdef __KERNEL__ Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 05/13] Hide some of "struct elf_prstatus" behind #ifdef __KERNEL__ Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 06/13] Hide ep_take_care_of_epollwakeup() " Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 07/13] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 08/13] Hide MAX_SHARED_LIBS behind #ifdef __KERNEL__ Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 09/13] Hide bp_type_idx " Palmer Dabbelt
2015-09-10 11:11 ` David Howells
2015-09-09 21:08 ` [PATCH 10/13] Hide USE_WCACHING " Palmer Dabbelt
2015-09-10 11:12 ` David Howells
2015-09-09 21:08 ` [PATCH 11/13] Hide MAX_RAW_MINORS " Palmer Dabbelt
2015-09-10 11:13 ` David Howells
2015-09-09 21:08 ` [PATCH 12/13] Hide AT_VECTOR_SIZE_ARCH " Palmer Dabbelt
2015-09-10 11:14 ` David Howells
[not found] ` <1441832902-28993-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>
2015-09-09 21:08 ` [PATCH 02/13] Always expose __SYSCALL(... fork ...) Palmer Dabbelt
2015-09-09 21:08 ` Palmer Dabbelt [this message]
2015-09-10 11:15 ` [PATCH] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h David Howells
[not found] ` <18147.1441883729-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2015-09-10 11:18 ` David Howells
2015-09-14 22:50 ` Palmer Dabbelt
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=1441832902-28993-14-git-send-email-palmer@dabbelt.com \
--to=palmer-96lfi9zocfxbdgjk7y7tuq@public.gmane.org \
--cc=3chas3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.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