From: Palmer Dabbelt <palmer@dabbelt.com>
To: arnd@arndb.de
To: dhowells@redhat.com
To: peterz@infradead.org
Cc: viro@zeniv.linux.org.uk
Cc: ast@plumgrid.com
Cc: aishchuk@linux.vnet.ibm.com
Cc: aarcange@redhat.com
Cc: akpm@linux-foundation.org
Cc: luto@kernel.org
Cc: acme@kernel.org
Cc: bhe@redhat.com
Cc: 3chas3@gmail.com
Cc: chris@zankel.net
Cc: dave@sr71.net
Cc: dyoung@redhat.com
Cc: drysdale@google.com
Cc: davem@davemloft.net
Cc: ebiederm@xmission.com
Cc: geoff@infradead.org
Cc: gregkh@linuxfoundation.org
Cc: hpa@zytor.com
Cc: mingo@kernel.org
Cc: iulia.manda21@gmail.com
Cc: plagnioj@jcrosoft.com
Cc: jikos@kernel.org
Cc: josh@joshtriplett.org
Cc: linux-api@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-xtensa@linux-xtensa.org
Cc: mathieu.desnoyers@efficios.com
Cc: jcmvbkbc@gmail.com
Cc: paulmck@linux.vnet.ibm.com
Cc: a.p.zijlstra@chello.nl
Cc: tglx@linutronix.de
Cc: tomi.valkeinen@ti.com
Cc: vgoyal@redhat.com
Cc: x86@kernel.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Subject: [PATCH 14/14] Re-enable and clean up "check_config()" in headers_check.pl
Date: Mon, 9 Nov 2015 17:31:11 -0800 [thread overview]
Message-ID: <1447119071-19392-15-git-send-email-palmer@dabbelt.com> (raw)
In-Reply-To: <1447119071-19392-1-git-send-email-palmer@dabbelt.com>
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@dabbelt.com>
Reviewed-by: Andrew Waterman <waterman@eecs.berkeley.edu>
Reviewed-by: Albert Ou <aou@eecs.berkeley.edu>
---
| 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
--git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 62320f9..1634b51 100755
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -27,6 +27,7 @@ my $ret = 0;
my $line;
my $lineno = 0;
my $filename;
+my $check_config_in_multiline_comment = 0;
foreach my $file (@files) {
$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
&check_asm_types();
&check_sizetypes();
&check_declarations();
- # Dropped for now. Too much noise &check_config();
+ &check_config();
}
close $fh;
}
@@ -78,7 +79,21 @@ sub check_declarations
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.10
next prev parent reply other threads:[~2015-11-10 1:33 UTC|newest]
Thread overview: 93+ 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 02/13] Always expose __SYSCALL(... fork ...) 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-09 21:08 ` [PATCH 10/13] Hide USE_WCACHING " Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 11/13] Hide MAX_RAW_MINORS " Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 12/13] Hide AT_VECTOR_SIZE_ARCH " Palmer Dabbelt
2015-09-09 21:08 ` [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl Palmer Dabbelt
2015-09-10 11:11 ` [PATCH 09/13] Hide bp_type_idx behind #ifdef __KERNEL__ David Howells
2015-09-10 11:12 ` [PATCH 10/13] Hide USE_WCACHING " David Howells
2015-09-10 11:13 ` [PATCH 11/13] Hide MAX_RAW_MINORS " David Howells
2015-09-10 11:14 ` [PATCH 12/13] Hide AT_VECTOR_SIZE_ARCH " David Howells
2015-09-14 22:50 ` [PATCH v3] Remove #ifdef CONFIG_* from all userspace headers Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 01/13] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 02/13] Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt
2015-09-15 0:23 ` Kirill A. Shutemov
2015-09-15 0:52 ` Palmer Dabbelt
2015-09-15 5:19 ` Josh Triplett
2015-09-15 9:42 ` Kirill A. Shutemov
2015-09-15 14:07 ` Josh Triplett
2015-09-17 10:13 ` David Howells
2015-09-14 22:50 ` [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 06/13] Move ep_take_care_of_epollwakeup() to fs/eventpoll.c Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 07/13] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 08/13] Move MAX_SHARED_LIBS to fs/binfmt_flat.c Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Palmer Dabbelt
2015-09-15 8:06 ` Peter Zijlstra
2015-09-15 18:40 ` Palmer Dabbelt
2015-09-15 19:39 ` Peter Zijlstra
2015-09-17 3:56 ` Palmer Dabbelt
2015-09-15 21:15 ` Arnd Bergmann
2015-09-24 12:15 ` Frederic Weisbecker
2015-09-17 10:28 ` David Howells
2015-09-14 22:50 ` [PATCH 10/13] Move USE_WCACHING to drivers/block/pktcdvd.c Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 11/13] Always define MAX_RAW_MINORS as 65535 in userspace Palmer Dabbelt
2015-09-15 20:42 ` H. Peter Anvin
2015-09-17 3:08 ` Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 12/13] Remove AT_VECTOR_SIZE_ARCH on x86 Palmer Dabbelt
2015-09-14 22:50 ` [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl Palmer Dabbelt
2015-09-17 9:57 ` [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c David Howells
2015-09-17 20:53 ` Palmer Dabbelt
2015-09-17 10:17 ` [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" David Howells
2015-11-03 19:46 ` [PATCH v4] Remove #ifdef CONFIG_* from all userspace headers Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 01/13] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 02/13] Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 06/13] Move ep_take_care_of_epollwakeup() to fs/eventpoll.c Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 07/13] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 08/13] Move MAX_SHARED_LIBS to fs/binfmt_flat.c Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Palmer Dabbelt
2015-11-03 21:28 ` kbuild test robot
2015-11-03 21:29 ` kbuild test robot
2015-11-04 11:41 ` Peter Zijlstra
2015-11-04 12:21 ` Peter Zijlstra
2015-11-07 6:44 ` Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 10/13] Move USE_WCACHING to drivers/block/pktcdvd.c Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 11/13] Always define MAX_RAW_MINORS as 2**20 in userspace Palmer Dabbelt
2015-11-03 20:11 ` kbuild test robot
2015-11-03 19:46 ` [PATCH 12/13] Remove AT_VECTOR_SIZE_ARCH on x86 Palmer Dabbelt
2015-11-03 19:46 ` [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl Palmer Dabbelt
2015-11-03 20:25 ` kbuild test robot
2015-11-03 20:26 ` kbuild test robot
2015-11-10 1:30 ` [PATCH v5] Remove #ifdef CONFIG_* from all userspace headers Palmer Dabbelt
2015-11-10 1:30 ` [PATCH 01/14] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt
2015-11-10 1:30 ` [PATCH 02/14] Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 03/14] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c Palmer Dabbelt
2023-02-10 14:55 ` Thomas Huth
2023-02-10 15:10 ` Arnd Bergmann
2015-11-10 1:31 ` [PATCH 04/14] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 05/14] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 06/14] Move ep_take_care_of_epollwakeup() to fs/eventpoll.c Palmer Dabbelt
2023-02-10 14:45 ` Thomas Huth
2015-11-10 1:31 ` [PATCH 07/14] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 08/14] Move MAX_SHARED_LIBS to fs/binfmt_flat.c Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 09/14] Move bp_type_idx to include/linux/hw_breakpoint.h Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 10/14] Move USE_WCACHING to drivers/block/pktcdvd.c Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 11/14] Always define MAX_RAW_MINORS as 2**20 in userspace Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 12/14] Remove AT_VECTOR_SIZE_ARCH on x86 Palmer Dabbelt
2015-11-10 1:31 ` [PATCH 13/14] Hide CONFIG_PHY_RAM_BASE_ADDRESS from userspace Palmer Dabbelt
2015-11-10 1:31 ` Palmer Dabbelt [this message]
2015-09-10 11:15 ` [PATCH] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h David Howells
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=1447119071-19392-15-git-send-email-palmer@dabbelt.com \
--to=palmer@dabbelt.com \
--cc=arnd@arndb.de \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).