summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Dyer <nick.dyer@itdev.co.uk>2013-06-07 15:45:13 +0100
committerMaciej Wereski <m.wereski@partner.samsung.com>2015-03-23 18:33:25 +0100
commitb4c82cb9ffd7e2897fdefb3eedd4ecdf3139ff34 (patch)
tree924a9f2c8fc2f708def9dad263246b78459b674f
parentfc3e2fb2778e3d7803b2b96d177578782f44c49f (diff)
downloadlinux-3.10-b4c82cb9ffd7e2897fdefb3eedd4ecdf3139ff34.tar.gz
linux-3.10-b4c82cb9ffd7e2897fdefb3eedd4ecdf3139ff34.tar.bz2
linux-3.10-b4c82cb9ffd7e2897fdefb3eedd4ecdf3139ff34.zip
sysfs_notify is only possible on file attributes
If sysfs_notify is called on a binary attribute, bad things can happen, so prevent it. Note, no in-kernel usage of this is currently present, but in the future, it's good to be safe. Changes in V2: - Also ignore sysfs_notify on dirs, links - Use WARN_ON rather than silently failing - Compiled and tested (huge apologies about first submission) Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/sysfs/file.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 602f56db044..d2bb7ed8fa7 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -449,10 +449,12 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
- od = sd->s_attr.open;
- if (od) {
- atomic_inc(&od->event);
- wake_up_interruptible(&od->poll);
+ if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
+ od = sd->s_attr.open;
+ if (od) {
+ atomic_inc(&od->event);
+ wake_up_interruptible(&od->poll);
+ }
}
spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);