linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: catch all world writable debugfs_create_file
@ 2015-03-13 19:23 Nicholas Mc Guire
  2015-03-13 20:16 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Nicholas Mc Guire @ 2015-03-13 19:23 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Joe Perches, linux-kernel, Nicholas Mc Guire

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

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

The patch was tested against a set of trivial test-cases:
t_file = debugfs_create_file("id", S_IWOTH, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IWUGO, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IRWXUGO, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IALLUGO, t_dir, NULL, &t_fops);
and
t_file = debugfs_create_file("id", S_IWOTH | S_IXOTH, t_dir, NULL, &t_fops);

Patch is against 4.0-rc3 (localversion-next is -next-20150313)

 scripts/checkpatch.pl |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6b79beb..5def21c 100755
--- 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/ ) {
 			WARN("EXPORTED_WORLD_WRITABLE",
 			     "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
 		}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-18  5:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 19:23 [PATCH] checkpatch: catch all world writable debugfs_create_file Nicholas Mc Guire
2015-03-13 20:16 ` Joe Perches
2015-03-13 20:42 ` Joe Perches
2015-03-13 23:43 ` [PATCH] checkpatch: match more world writable permissions Joe Perches
2015-03-14  7:35   ` Nicholas Mc Guire
2015-03-14 14:32   ` Guenter Roeck
2015-03-14 15:42     ` Joe Perches
2015-03-17 23:17   ` Andrew Morton
2015-03-18  5:56     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).