History

checkpatch: match more world writable permissions

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. [akpm@linux-foundation.org: remove stray $] Signed-off-by: Joe Perches <joe@perches.com> Original-patch-by: Nicholas Mc Guire <hofrat@osadl.org> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Joe Perches committed 11 years ago

Commit b392c641 parent ebfd7d61 file · +10 −2Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+10−2
@@ -443,6 +443,14 @@ foreach my $entry (@mode_permission_funcs) { · 442 unmodified lines
443443 $mode_perms_search .= $entry->[0];
444444 }
445445
446+our $mode_perms_world_writable = qr{
447+ S_IWUGO |
448+ S_IWOTH |
449+ S_IRWXUGO |
450+ S_IALLUGO |
451+ 0[0-7][0-7][2367]
452+}x;
453+
446454 our $allowed_asm_includes = qr{(?x:
447455 irq|
448456 memory|
@@ -5356,8 +5364,8 @@ sub process { · 4907 unmodified lines
53565364 }
53575365 }
53585366
5359− if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
5360− $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
5367+ if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ ||
5368+ $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) {
53615369 WARN("EXPORTED_WORLD_WRITABLE",
53625370 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
53635371 }