From patchwork Tue Nov 10 01:31:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 7587371 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C011DC05C6 for ; Tue, 10 Nov 2015 01:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E83A62068C for ; Tue, 10 Nov 2015 01:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1810205DD for ; Tue, 10 Nov 2015 01:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752457AbbKJBdl (ORCPT ); Mon, 9 Nov 2015 20:33:41 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36303 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752495AbbKJBcD (ORCPT ); Mon, 9 Nov 2015 20:32:03 -0500 Received: by pacdm15 with SMTP id dm15so192693939pac.3 for ; Mon, 09 Nov 2015 17:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt_com.20150623.gappssmtp.com; s=20150623; h=from:to:to:to:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:subject :date:message-id:in-reply-to:references; bh=FRdxeNjbjWuKKoGyZhh1aKSTXRP5pTKcY+BtvNHqQMU=; b=lSQwVVMmF8MH5uPswgUlZXH2xOWpCbgKEWLuhjQnAc0puZfHefqmBZn/ZTlcdSayoq j+gfSCiWrLj4uVPwcCuqGf+eom1vu9C9lk8AlcTW6iSnQXKxijXrTlY7G6YWJMDcJD0w XnREd7ev/KTSg0oSh4d2d2ctvEvHdylAcqJ19GEkFeeUe31DD2tjlLW+tUzpzByWBDwy QtGXnhxqnemqy3jEjBT3QNk6+oe5AAfk/y3tTySk5N9umBE7lz0LLQ9tG8zA4rUkIt1Z FP1UcMAukghhNoxJv/vHnfnYQ567qJYEtsZf4cjGRlzT6Tgn5/+xt9aYrKfbyHrRw7Lg 65Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:to:to:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:subject:date:message-id:in-reply-to:references; bh=FRdxeNjbjWuKKoGyZhh1aKSTXRP5pTKcY+BtvNHqQMU=; b=de8cd4Ruv9btcxb7K7U1sMnvwlVj5O7+L8Kr/RWoIkP0ycC8f+4w/88VglH3zxVbYC fGwssFU6Of0wttwwy2A9vx9XpB+v7ZPwERC9Sd4Sw989GCbF7PPH5iMHWbth09tGU7b0 38RxtlaIyVx7GkDN7im6tnU5tae9TUDKHQDywZHUVL9/PBJ7JJlTGHZO/fXaajJnvkjM 7oB1AWWSEFKsR00N9WiAw1hUXD5ZnYmXUmcVSG8i36eTBuc3EcaTmJ55/Y79rHCi99nH 0+4dItrFqrT0C/DUTXE+T6Z6p6B1cnl7rb2hHS6suvlgiq4dAUkc9Dcxtonx+EojkS1w pi4w== X-Gm-Message-State: ALoCoQm7y2amd5qECA4we7bc5khel5HvSBHTwZoGzUjsA4OMmIYjt5ofjztQY6f9HwT8fqrDYT4F X-Received: by 10.66.254.197 with SMTP id ak5mr1542121pad.130.1447119122972; Mon, 09 Nov 2015 17:32:02 -0800 (PST) Received: from localhost (wap-cal.CS.Berkeley.EDU. [128.32.35.228]) by smtp.gmail.com with ESMTPSA id er1sm622695pbb.6.2015.11.09.17.32.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 17:32:02 -0800 (PST) From: Palmer Dabbelt 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 Subject: [PATCH 14/14] Re-enable and clean up "check_config()" in headers_check.pl Date: Mon, 9 Nov 2015 17:31:11 -0800 Message-Id: <1447119071-19392-15-git-send-email-palmer@dabbelt.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1447119071-19392-1-git-send-email-palmer@dabbelt.com> References: <1446579994-9937-1-git-send-email-palmer@dabbelt.com> <1447119071-19392-1-git-send-email-palmer@dabbelt.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Andrew Waterman Reviewed-by: Albert Ou --- scripts/headers_check.pl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --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"; } }