[PATCH RFC] checkpatch: fix for catching all world writable settings

From: Nicholas Mc Guire
Date: Sun Dec 28 2014 - 11:45:42 EST


Currently checkpatch will fuss if one uses world writable settings in debugfs
files by passing S_IWUGO but not when passing S_IRWXUGO. This patch extends
the check to cover the S_IRWXUGO case.

tested on trivial examples:
WARNING: Exporting world writable files is usually an error. Consider more
restrictive permissions.
#72: FILE: test.c:72:
+ id_file = debugfs_create_file("id", S_IRUGO | S_IWUGO, my_dir,

with the patch applied it also fusses now in the S_IRWXUGO case.
WARNING: Exporting world writable files is usually an error. Consider more
restrictive permissions.
#72: FILE: test.c:72:
+ id_file = debugfs_create_file("id", S_IRWXUGO, my_dir,

patch is against linux-next 3.19.0-rc1 -next-20141226

Signed-off-by: Nicholas Mc Guire <der.herr@xxxxxxx>
---
scripts/checkpatch.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f0bb6d6..48120b1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5227,7 +5227,9 @@ sub process {
}

if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
- $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
+ $line =~ /debugfs_create_file.*S_IRWXUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IWUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IRWXUGO/ ) {
WARN("EXPORTED_WORLD_WRITABLE",
"Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
}
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/