From patchwork Wed Sep 9 21:08:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 7149031 Return-Path: X-Original-To: patchwork-linux-fbdev@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 DC04DBEEC1 for ; Wed, 9 Sep 2015 21:13:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18BA620959 for ; Wed, 9 Sep 2015 21:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21E9B2096E for ; Wed, 9 Sep 2015 21:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755046AbbIIVJZ (ORCPT ); Wed, 9 Sep 2015 17:09:25 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:36235 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754872AbbIIVJA (ORCPT ); Wed, 9 Sep 2015 17:09:00 -0400 Received: by padhk3 with SMTP id hk3so20677891pad.3 for ; Wed, 09 Sep 2015 14:08:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:subject:date:message-id:in-reply-to:references; bh=MYEo9zvFQ+5twsaZ5seVgv5DvsGSurb8AKrH+PJbaUY=; b=JVRGr2SR2ihF4tgWY+ShbQx7i/gt4G4ftLnu95APwr9mCv1DQiENF/JDiy6/PZ2hp0 MAjEIeoFlaZPD/GT7umSO+B318LzzBPF57MpDRbSAdwCLXbfRazs+izWTlSkCb+pCqf2 syEj5fTwrj9+Rc+NU4WFEVInB/FnLuuPQTNUhF8u44/hPUq1ALc5vj8fbCODfTvNEqv3 lNXQSWtYnibEb5rfwLEpH80cBhL8Lymmpy9n8hAxbsL7kHoEhJAl1VMXfphBZG4qtiGf uY1hKU4hqDto2/IQae/MNqF6tOC6kZB06RvGiNktgh36bFLbq7+Ui0e1M1QUCq/fvCsB tsTg== X-Gm-Message-State: ALoCoQk1VkhCVKIYhQ34RZXSrOLK7ot7bQv4Qk5WV5Ko0JYOuc68ht0rh8TJFwpnMx/obXaTpCag X-Received: by 10.66.216.1 with SMTP id om1mr58919009pac.51.1441832939845; Wed, 09 Sep 2015 14:08:59 -0700 (PDT) Received: from localhost (wap-cal.CS.Berkeley.EDU. [128.32.35.228]) by smtp.gmail.com with ESMTPSA id gw3sm8013004pbc.46.2015.09.09.14.08.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 14:08:59 -0700 (PDT) From: Palmer Dabbelt To: arnd@arndb.de Cc: 3chas3@gmail.com Cc: hpa@zytor.com Cc: mingo@redhat.com Cc: plagnioj@jcrosoft.com Cc: jikos@kernel.org Cc: linux-api@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-atm-general@lists.sourceforge.net Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org Cc: tglx@linutronix.de Cc: tomi.valkeinen@ti.com Cc: x86@kernel.org Cc: Palmer Dabbelt Subject: [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl Date: Wed, 9 Sep 2015 14:08:22 -0700 Message-Id: <1441832902-28993-14-git-send-email-palmer@dabbelt.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1441832902-28993-1-git-send-email-palmer@dabbelt.com> References: <2644177.lVCYzIBfPW@wuerfel> <1441832902-28993-1-git-send-email-palmer@dabbelt.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 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"; } }