From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754403AbbCMXnr (ORCPT ); Fri, 13 Mar 2015 19:43:47 -0400 Received: from smtprelay0113.hostedemail.com ([216.40.44.113]:51208 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751826AbbCMXnq (ORCPT ); Fri, 13 Mar 2015 19:43:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 64,4,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2332:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3352:3653:3865:3867:3868:3870:3871:4321:5007:6261:7903:10004:10400:10848:11026:11473:11658:11914:12043:12296:12438:12517:12519:12555:13069:13311:13357:14394:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: boys03_20b4b98022011 X-Filterd-Recvd-Size: 2241 Message-ID: <1426290223.11459.62.camel@perches.com> Subject: [PATCH] checkpatch: match more world writable permissions From: Joe Perches To: Nicholas Mc Guire , Andrew Morton Cc: Andy Whitcroft , linux-kernel@vger.kernel.org Date: Fri, 13 Mar 2015 16:43:43 -0700 In-Reply-To: <1426274602-21196-1-git-send-email-hofrat@osadl.org> References: <1426274602-21196-1-git-send-email-hofrat@osadl.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently checkpatch will fuss if one uses world writable settings in debugfs files and DEVICE_ATTR uses by testing S_IWUGO but not testing S_IWOTH, S_IRWXUGO or S_IALLUGO. Extend the check to catch all cases exporting world writable permissions including octal values. Original-patch-by: Nicholas Mc Guire Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6b79beb..4f07d50 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -443,6 +443,14 @@ foreach my $entry (@mode_permission_funcs) { $mode_perms_search .= $entry->[0]; } +$our $mode_perms_world_writable = qr{ + S_IWUGO | + S_IWOTH | + S_IRWXUGO | + S_IALLUGO | + 0[0-7][0-7][2367] +}x; + our $allowed_asm_includes = qr{(?x: irq| memory| @@ -5356,8 +5364,8 @@ sub process { } } - if ($line =~ /debugfs_create_file.*S_IWUGO/ || - $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { + if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ || + $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) { WARN("EXPORTED_WORLD_WRITABLE", "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); }