From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755932AbbCNOcU (ORCPT ); Sat, 14 Mar 2015 10:32:20 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:45784 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481AbbCNOcQ (ORCPT ); Sat, 14 Mar 2015 10:32:16 -0400 Date: Sat, 14 Mar 2015 07:32:00 -0700 From: Guenter Roeck To: Joe Perches Cc: Nicholas Mc Guire , Andrew Morton , Andy Whitcroft , linux-kernel@vger.kernel.org Subject: Re: [PATCH] checkpatch: match more world writable permissions Message-ID: <20150314143200.GA19645@roeck-us.net> References: <1426274602-21196-1-git-send-email-hofrat@osadl.org> <1426290223.11459.62.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426290223.11459.62.camel@perches.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CTCH-PVer: 0000001 X-CTCH-Spam: Unknown X-CTCH-VOD: Unknown X-CTCH-Flags: 0 X-CTCH-RefID: str=0001.0A020203.55044670.0018,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-Score: 0.001 X-CTCH-ScoreCust: 0.000 X-CTCH-Rules: C_4847, X-CTCH-SenderID: linux@roeck-us.net X-CTCH-SenderID-Flags: 0 X-CTCH-SenderID-TotalMessages: 5 X-CTCH-SenderID-TotalSpam: 0 X-CTCH-SenderID-TotalSuspected: 0 X-CTCH-SenderID-TotalConfirmed: 0 X-CTCH-SenderID-TotalBulk: 0 X-CTCH-SenderID-TotalVirus: 0 X-CTCH-SenderID-TotalRecipients: 0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: mailgid no entry from get_relayhosts_entry X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 13, 2015 at 04:43:43PM -0700, Joe Perches wrote: > 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); With https://lkml.org/lkml/2015/3/12/412 in mind, maybe this should be marked as error, at least for sysfs attributes. Thanks, Guenter