[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1426274602-21196-1-git-send-email-hofrat@osadl.org>
Date: Fri, 13 Mar 2015 15:23:22 -0400
From: Nicholas Mc Guire <hofrat@...dl.org>
To: Andy Whitcroft <apw@...onical.com>
Cc: Joe Perches <joe@...ches.com>, linux-kernel@...r.kernel.org,
Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH] checkpatch: catch all world writable debugfs_create_file
Currently checkpatch will fuss if one uses world writable settings in debugfs
files by passing S_IWUGO but not when passing S_IWOTH, S_IRWXUGO or S_IALLUGO.
This patch extends the check to catches all cases exporting world writable
files
Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---
The patch was tested against a set of trivial test-cases:
t_file = debugfs_create_file("id", S_IWOTH, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IWUGO, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IRWXUGO, t_dir, NULL, &t_fops);
t_file = debugfs_create_file("id", S_IALLUGO, t_dir, NULL, &t_fops);
and
t_file = debugfs_create_file("id", S_IWOTH | S_IXOTH, t_dir, NULL, &t_fops);
Patch is against 4.0-rc3 (localversion-next is -next-20150313)
scripts/checkpatch.pl | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6b79beb..5def21c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5356,8 +5356,14 @@ sub process {
}
}
- if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
- $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
+ if ($line =~ /debugfs_create_file.*S_IWOTH/ ||
+ $line =~ /debugfs_create_file.*S_IWUGO/ ||
+ $line =~ /debugfs_create_file.*S_IRWXUGO/ ||
+ $line =~ /debugfs_create_file.*S_IALLUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IWOTH/ ||
+ $line =~ /DEVICE_ATTR.*S_IWUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IRWXUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IALLUGO/ ) {
WARN("EXPORTED_WORLD_WRITABLE",
"Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists