base: memory: fix soft/hard_offline_page permissions
Subsystems (2)
PATCH 1/2 base: memory: fix soft/hard_offline_page permissions
those two sysfs files don't have a 'show' method, so they shouldn't have a read permission. Thanks to Greg Kroah-Hartman for actually looking into the source code and figuring out we had a real bug with these two files.
--- drivers/base/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/memory.c +2 -2
@@ -494,8 +494,8 @@ store_hard_offline_page(struct device *dev,return ret ? ret : count; } -static DEVICE_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); -static DEVICE_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); +static DEVICE_ATTR(soft_offline_page, S_IWUSR, NULL, store_soft_offline_page); +static DEVICE_ATTR(hard_offline_page, S_IWUSR, NULL, store_hard_offline_page);static __init int memory_fail_init (void ) {
Signature · 1 line
1.8.1.rc1.5.g7e0651a
PATCH 2/2 base: core: WARN() about bogus permissions on device attributes
Whenever a struct device_attribute is registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.
---
This is completely untested. I have only compile tested to make sure I'm not breaking anything.
Greg, do you think this would be nice to have ? I could fire up kvm tomorrow and run on a few of my OMAP-based boards to make sure it works as expected.
drivers/base/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/base/core.c +8 -1
@@ -563,8 +563,15 @@ int device_create_file(struct device *dev, const struct device_attribute *attr) {int error =0 ; -if (dev) + +if (dev) { +WARN (((attr->attr.mode &S_IWUGO ) && !attr->store), +"Write permission without 'store'\n" ); +WARN (((attr->attr.mode &S_IRUGO ) && !attr->show), +"Read permission without 'show'\n" ); error =sysfs_create_file (&dev->kobj, &attr->attr); + } +return error; }
Signature · 1 line
1.8.1.rc1.5.g7e0651a
Greg KH
maintainerRe: [BONUS PATCH 2/2] base: core: WARN() about bogus permissions on device attributes
Quoted 7 lines · Felipe Balbi
Whenever a struct
device_attributeis registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.Signed-off-by Felipe Balbi <[email protected]>
Quoted 8 lines
---
This is completely untested. I have only compile tested to make sure I'm not breaking anything.
Greg, do you think this would be nice to have ? I could fire up kvm tomorrow and run on a few of my OMAP-based boards to make sure it works as expected.
Looks good, but you better fix up all of the big offenders that this points out, before I apply it, otherwise we will get a ton of bug reports :)
thanks,
greg k-h
Re: [BONUS PATCH 2/2] base: core: WARN() about bogus permissions on device attributes
Quoted 13 lines · Greg KH
Quoted 12 lines · Felipe Balbi
Whenever a struct
device_attributeis registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.Signed-off-by Felipe Balbi <[email protected]>---
This is completely untested. I have only compile tested to make sure I'm not breaking anything.
Quoted 7 lines
Quoted 3 lines
Greg, do you think this would be nice to have ? I could fire up kvm tomorrow and run on a few of my OMAP-based boards to make sure it works as expected.
Looks good, but you better fix up all of the big offenders that this points out, before I apply it, otherwise we will get a ton of bug reports :)
sure, will do that tomorrow though ;-)
Signature · 1 line
balbi
Re: [BONUS PATCH 2/2] base: core: WARN() about bogus permissions on device attributes
Hi,
Quoted 18 lines · Felipe Balbi
Quoted 17 lines · Greg KH
Quoted 15 lines · Felipe Balbi
Whenever a struct
device_attributeis registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.Signed-off-by Felipe Balbi <[email protected]>---
This is completely untested. I have only compile tested to make sure I'm not breaking anything.
Greg, do you think this would be nice to have ? I could fire up kvm tomorrow and run on a few of my OMAP-based boards to make sure it works as expected.
Quoted 5 lines
Quoted 3 lines
Looks good, but you better fix up all of the big offenders that this points out, before I apply it, otherwise we will get a ton of bug reports :)
sure, will do that tomorrow though ;-)
Just tested $SUBJECT and it didn't trigger any extra warnings. Only the one whose fix you already applied (I reverted it to make sure $SUBJECT was working as expected).
Signature · 1 line
balbi
Greg KH
maintainerRe: [BONUS PATCH 2/2] base: core: WARN() about bogus permissions on device attributes
Quoted 25 lines · Felipe Balbi
Hi,
Quoted 22 lines · Felipe Balbi
Quoted 20 lines · Greg KH
Quoted 7 lines · Felipe Balbi
Whenever a struct
device_attributeis registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.Signed-off-by Felipe Balbi <[email protected]>Quoted 8 lines
---
This is completely untested. I have only compile tested to make sure I'm not breaking anything.
Greg, do you think this would be nice to have ? I could fire up kvm tomorrow and run on a few of my OMAP-based boards to make sure it works as expected.
Looks good, but you better fix up all of the big offenders that this points out, before I apply it, otherwise we will get a ton of bug reports :)
Quoted 5 lines
Quoted 1 line
sure, will do that tomorrow though ;-)
Just tested $SUBJECT and it didn't trigger any extra warnings. Only the one whose fix you already applied (I reverted it to make sure $SUBJECT was working as expected).
Ok, care to resend so that I can queue it up after 3.9-rc1 is out, for inclusion in 3.10, and we can have lots of time to see what falls out?
thanks,
greg k-h
PATCH 1/1 base: core: WARN() about bogus permissions on device attributes
Whenever a struct device_attribute is registered with mismatched permissions - read permission without a show routine or write permission without store routine - we will issue a big warning so we catch those early enough.
--- drivers/base/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/base/core.c +8 -1
@@ -563,8 +563,15 @@ int device_create_file(struct device *dev, const struct device_attribute *attr) {int error =0 ; -if (dev) + +if (dev) { +WARN (((attr->attr.mode &S_IWUGO ) && !attr->store), +"Write permission without 'store'\n" ); +WARN (((attr->attr.mode &S_IRUGO ) && !attr->show), +"Read permission without 'show'\n" ); error =sysfs_create_file (&dev->kobj, &attr->attr); + } +return error; }
Signature · 1 line
1.8.1.rc1.5.g7e0651a