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>
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -443,6 +443,14 @@ foreach my $entry (@mode_permission_funcs) { · 442 unmodified lines | |||
| 443 | $mode_perms_search .= $entry->[0]; | 443 | $mode_perms_search .= $entry->[0]; |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 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 | |||
| 446 | our $allowed_asm_includes = qr{(?x: | 454 | our $allowed_asm_includes = qr{(?x: |
| 447 | irq| | 455 | irq| |
| 448 | memory| | 456 | memory| |
| @@ -5356,8 +5364,8 @@ sub process { · 4907 unmodified lines | |||
| 5356 | } | 5364 | } |
| 5357 | } | 5365 | } |
| 5358 | 5366 | ||
| 5359 | if ($line =~ /debugfs_create_file.*S_IWUGO/ || | 5367 | if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ || |
| 5360 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { | 5368 | $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) { |
| 5361 | WARN("EXPORTED_WORLD_WRITABLE", | 5369 | WARN("EXPORTED_WORLD_WRITABLE", |
| 5362 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | 5370 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); |
| 5363 | } | 5371 | } |