Add world writable permissions tests for the various functions like debugfs etc... Add $String type for $FuncArg so that string constants are matched.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -298,6 +298,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; · 297 unmodified lines | ||
| 298 | 298 | our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; |
| 299 | 299 | our $Int = qr{[0-9]+$Int_type?}; |
| 300 | 300 | our $Octal = qr{0[0-7]+$Int_type?}; |
| 301 | +our $String = qr{"[X\t]*"}; | |
| 301 | 302 | our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; |
| 302 | 303 | our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; |
| 303 | 304 | 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 | ||
| 517 | 518 | |
| 518 | 519 | our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; |
| 519 | 520 | 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)}; | |
| 521 | 522 | |
| 522 | 523 | our $declaration_macros = qr{(?x: |
| 523 | 524 | (?:$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 | ||
| 5261 | 5262 | length($val) ne 4)) { |
| 5262 | 5263 | ERROR("NON_OCTAL_PERMISSIONS", |
| 5263 | 5264 | "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); | |
| 5264 | 5268 | } |
| 5265 | 5269 | } |
| 5266 | 5270 | } |