diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2014-03-23 21:30:34 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-03-23 21:51:00 -0400 |
commit | 58f86cc89c3372d3e61d5b71e5513ec5a0b02848 (patch) | |
tree | ba12cb68846c5e4e04d3442528dee70e58100859 /include/linux/kernel.h | |
parent | c6bda7c988a57958108741cde9b1f12e9727a938 (diff) |
VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.
Summary of http://lkml.org/lkml/2014/3/14/363 :
Ted: module_param(queue_depth, int, 444)
Joe: 0444!
Rusty: User perms >= group perms >= other perms?
Joe: CLASS_ATTR, DEVICE_ATTR, SENSOR_ATTR and SENSOR_ATTR_2?
Side effect of stricter permissions means removing the unnecessary
S_IFREG from several callers.
Note that the BUILD_BUG_ON_ZERO((perm) & 2) test was removed: a fair
number of drivers fail this test, so that will be the debate for a
future patch.
Suggested-by: Joe Perches <joe@perches.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> for drivers/pci/slot.c
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 471090093c67..4679eddc110a 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -842,4 +842,12 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
842 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 842 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
843 | #endif | 843 | #endif |
844 | 844 | ||
845 | /* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ | ||
846 | #define VERIFY_OCTAL_PERMISSIONS(perms) \ | ||
847 | (BUILD_BUG_ON_ZERO((perms) < 0) + \ | ||
848 | BUILD_BUG_ON_ZERO((perms) > 0777) + \ | ||
849 | /* User perms >= group perms >= other perms */ \ | ||
850 | BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ | ||
851 | BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ | ||
852 | (perms)) | ||
845 | #endif | 853 | #endif |