linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <hofrat@osadl.org>
To: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>,
	linux-kernel@vger.kernel.org,
	Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH] checkpatch: catch all world writable debugfs_create_file
Date: Fri, 13 Mar 2015 15:23:22 -0400	[thread overview]
Message-ID: <1426274602-21196-1-git-send-email-hofrat@osadl.org> (raw)

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@osadl.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


             reply	other threads:[~2015-03-13 19:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 19:23 Nicholas Mc Guire [this message]
2015-03-13 20:16 ` [PATCH] checkpatch: catch all world writable debugfs_create_file Joe Perches
2015-03-13 20:42 ` Joe Perches
2015-03-13 23:43 ` [PATCH] checkpatch: match more world writable permissions Joe Perches
2015-03-14  7:35   ` Nicholas Mc Guire
2015-03-14 14:32   ` Guenter Roeck
2015-03-14 15:42     ` Joe Perches
2015-03-17 23:17   ` Andrew Morton
2015-03-18  5:56     ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426274602-21196-1-git-send-email-hofrat@osadl.org \
    --to=hofrat@osadl.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).