From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754380AbbCMT1s (ORCPT ); Fri, 13 Mar 2015 15:27:48 -0400 Received: from www.osadl.org ([62.245.132.105]:59011 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752393AbbCMT1r (ORCPT ); Fri, 13 Mar 2015 15:27:47 -0400 From: Nicholas Mc Guire To: Andy Whitcroft Cc: Joe Perches , linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] checkpatch: catch all world writable debugfs_create_file Date: Fri, 13 Mar 2015 15:23:22 -0400 Message-Id: <1426274602-21196-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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