aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-05-21 05:59:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-05-21 05:59:25 -0400
commit439c6109922c8faa920c9b8680d63937189d6915 (patch)
tree686ad57dd77b9a462044e218b411ad9cdad63fb9 /fs
parent957cf2582adf2a2164bbbd87036138221c5c118a (diff)
parentf5c16f29bf5e57ba4051fc7785ba7f035f798c71 (diff)
Merge tag 'driver-core-3.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here are two driver core (well, sysfs) fixes for 3.15-rc6 that resolve some reported issues and a regression from 3.13" * tag 'driver-core-3.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: sysfs: make sure read buffer is zeroed kernfs, sysfs, cgroup: restrict extra perm check on open to sysfs
Diffstat (limited to 'fs')
-rw-r--r--fs/kernfs/file.c17
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--fs/sysfs/mount.c3
3 files changed, 14 insertions, 9 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index e01ea4a14a01..5e9a80cfc3d8 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -610,6 +610,7 @@ static void kernfs_put_open_node(struct kernfs_node *kn,
610static int kernfs_fop_open(struct inode *inode, struct file *file) 610static int kernfs_fop_open(struct inode *inode, struct file *file)
611{ 611{
612 struct kernfs_node *kn = file->f_path.dentry->d_fsdata; 612 struct kernfs_node *kn = file->f_path.dentry->d_fsdata;
613 struct kernfs_root *root = kernfs_root(kn);
613 const struct kernfs_ops *ops; 614 const struct kernfs_ops *ops;
614 struct kernfs_open_file *of; 615 struct kernfs_open_file *of;
615 bool has_read, has_write, has_mmap; 616 bool has_read, has_write, has_mmap;
@@ -624,14 +625,16 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)
624 has_write = ops->write || ops->mmap; 625 has_write = ops->write || ops->mmap;
625 has_mmap = ops->mmap; 626 has_mmap = ops->mmap;
626 627
627 /* check perms and supported operations */ 628 /* see the flag definition for details */
628 if ((file->f_mode & FMODE_WRITE) && 629 if (root->flags & KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK) {
629 (!(inode->i_mode & S_IWUGO) || !has_write)) 630 if ((file->f_mode & FMODE_WRITE) &&
630 goto err_out; 631 (!(inode->i_mode & S_IWUGO) || !has_write))
632 goto err_out;
631 633
632 if ((file->f_mode & FMODE_READ) && 634 if ((file->f_mode & FMODE_READ) &&
633 (!(inode->i_mode & S_IRUGO) || !has_read)) 635 (!(inode->i_mode & S_IRUGO) || !has_read))
634 goto err_out; 636 goto err_out;
637 }
635 638
636 /* allocate a kernfs_open_file for the file */ 639 /* allocate a kernfs_open_file for the file */
637 error = -ENOMEM; 640 error = -ENOMEM;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 28cc1acd5439..e9ef59b3abb1 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -47,12 +47,13 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
47 ssize_t count; 47 ssize_t count;
48 char *buf; 48 char *buf;
49 49
50 /* acquire buffer and ensure that it's >= PAGE_SIZE */ 50 /* acquire buffer and ensure that it's >= PAGE_SIZE and clear */
51 count = seq_get_buf(sf, &buf); 51 count = seq_get_buf(sf, &buf);
52 if (count < PAGE_SIZE) { 52 if (count < PAGE_SIZE) {
53 seq_commit(sf, -1); 53 seq_commit(sf, -1);
54 return 0; 54 return 0;
55 } 55 }
56 memset(buf, 0, PAGE_SIZE);
56 57
57 /* 58 /*
58 * Invoke show(). Control may reach here via seq file lseek even 59 * Invoke show(). Control may reach here via seq file lseek even
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index a66ad6196f59..8794423f7efb 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -63,7 +63,8 @@ int __init sysfs_init(void)
63{ 63{
64 int err; 64 int err;
65 65
66 sysfs_root = kernfs_create_root(NULL, 0, NULL); 66 sysfs_root = kernfs_create_root(NULL, KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK,
67 NULL);
67 if (IS_ERR(sysfs_root)) 68 if (IS_ERR(sysfs_root))
68 return PTR_ERR(sysfs_root); 69 return PTR_ERR(sysfs_root);
69 70