lkml.org 
[lkml]   [2015]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: catch all world writable debugfs_create_file
Date
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


\
 
 \ /
  Last update: 2015-03-13 21:01    [W:0.068 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site