History

checkpatch: improve octal permissions tests

Add world writable permissions tests for the various functions like debugfs etc... Add $String type for $FuncArg so that string constants are matched.

Joe Perches committed 11 years ago

Commit c0a5c891 parent 62ec8181 file · +5 −1Browse files

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

Unified · Split

scripts/checkpatch.pl+5−1
@@ -298,6 +298,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; · 297 unmodified lines
298298 our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
299299 our $Int = qr{[0-9]+$Int_type?};
300300 our $Octal = qr{0[0-7]+$Int_type?};
301+our $String = qr{"[X\t]*"};
301302 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
302303 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
303304 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -517,7 +518,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; · 213 unmodified lines
517518
518519 our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
519520 our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
520−our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
521+our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
521522
522523 our $declaration_macros = qr{(?x:
523524 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
@@ -5261,6 +5262,9 @@ sub process { · 4737 unmodified lines
52615262 length($val) ne 4)) {
52625263 ERROR("NON_OCTAL_PERMISSIONS",
52635264 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
5265+ } elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) {
5266+ ERROR("EXPORTED_WORLD_WRITABLE",
5267+ "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
52645268 }
52655269 }
52665270 }