aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-02-13 17:38:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:39 -0500
commitc0a5c89858337653d7b52ecbbcd9975a52359570 (patch)
tree3f4822ddd94b877839fee60274d3aaf0a1b6723f
parent62ec818f55ccc3e1a04a6634f8e541596778af5d (diff)
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. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rwxr-xr-xscripts/checkpatch.pl6
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 501c286369c9..2b77d96db735 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -298,6 +298,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?};
298our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; 298our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
299our $Int = qr{[0-9]+$Int_type?}; 299our $Int = qr{[0-9]+$Int_type?};
300our $Octal = qr{0[0-7]+$Int_type?}; 300our $Octal = qr{0[0-7]+$Int_type?};
301our $String = qr{"[X\t]*"};
301our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; 302our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
302our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; 303our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
303our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; 304our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -517,7 +518,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
517 518
518our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; 519our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
519our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; 520our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
520our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; 521our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
521 522
522our $declaration_macros = qr{(?x: 523our $declaration_macros = qr{(?x:
523 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(| 524 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
@@ -5261,6 +5262,9 @@ sub process {
5261 length($val) ne 4)) { 5262 length($val) ne 4)) {
5262 ERROR("NON_OCTAL_PERMISSIONS", 5263 ERROR("NON_OCTAL_PERMISSIONS",
5263 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); 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 }