From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753926AbbCMUQn (ORCPT ); Fri, 13 Mar 2015 16:16:43 -0400 Received: from smtprelay0130.hostedemail.com ([216.40.44.130]:48383 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750879AbbCMUQl (ORCPT ); Fri, 13 Mar 2015 16:16:41 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3352:3622:3653:3865:3867:3868:3870:3871:3872:3874:4321:5007:6261:7903:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12438:12517:12519:12740:13019:13069:13071:13311:13357:21060: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: balls03_7437427ad8354 X-Filterd-Recvd-Size: 2270 Message-ID: <1426277797.11459.27.camel@perches.com> Subject: Re: [PATCH] checkpatch: catch all world writable debugfs_create_file From: Joe Perches To: Nicholas Mc Guire Cc: Andy Whitcroft , linux-kernel@vger.kernel.org Date: Fri, 13 Mar 2015 13:16:37 -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 On Fri, 2015-03-13 at 15:23 -0400, Nicholas Mc Guire wrote: > Currently checkpatch will fuss if one uses world writable settings in debugfs > files by passing S_IWUGO but not when passing S_IWOTH, S_IRWXUGO or S_IALLUGO. > This patch extends the check to catches all cases exporting world writable > files Hi Nicholas > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -5356,8 +5356,14 @@ sub process { > } > } > > - if ($line =~ /debugfs_create_file.*S_IWUGO/ || > - $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { > + if ($line =~ /debugfs_create_file.*S_IWOTH/ || > + $line =~ /debugfs_create_file.*S_IWUGO/ || > + $line =~ /debugfs_create_file.*S_IRWXUGO/ || > + $line =~ /debugfs_create_file.*S_IALLUGO/ || > + $line =~ /DEVICE_ATTR.*S_IWOTH/ || > + $line =~ /DEVICE_ATTR.*S_IWUGO/ || > + $line =~ /DEVICE_ATTR.*S_IRWXUGO/ || > + $line =~ /DEVICE_ATTR.*S_IALLUGO/ ) { That seems sensible, but my preference would be to use a variable and extend it to find octal values like: $world_writable = qr{S_IWUGO|S_IWOTH|S_IWUGO|S_URWXUGO|S_IALLUGO|0[0-7][0-7][2367]}; if ($line =~ /debugfs_create_file.*\b$world_writable\b/ $line =~ /DEVICE_ATTR.*\b$world_writable\b/) > WARN("EXPORTED_WORLD_WRITABLE", > "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); > }