diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-01 14:05:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-01 14:05:59 -0400 |
commit | 0f8b1a0204a12441cddbbf5be31e6338e0b8da1c (patch) | |
tree | 7a546266d24908269049bde5cb40aade4b45b06a /fs/sysfs | |
parent | 928c0c1571b004917a989c4d92b09ac129ad68b2 (diff) | |
parent | 07961ac7c0ee8b546658717034fe692fd12eefa9 (diff) |
Merge v3.9-rc5 into driver-core-next
We want the fixes in here.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/dir.c | 17 | ||||
-rw-r--r-- | fs/sysfs/mount.c | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 7f968ede20d6..c6f54abe9852 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -1007,6 +1007,8 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
1007 | ino = parent_sd->s_ino; | 1007 | ino = parent_sd->s_ino; |
1008 | if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) == 0) | 1008 | if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) == 0) |
1009 | filp->f_pos++; | 1009 | filp->f_pos++; |
1010 | else | ||
1011 | return 0; | ||
1010 | } | 1012 | } |
1011 | if (filp->f_pos == 1) { | 1013 | if (filp->f_pos == 1) { |
1012 | if (parent_sd->s_parent) | 1014 | if (parent_sd->s_parent) |
@@ -1015,6 +1017,8 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
1015 | ino = parent_sd->s_ino; | 1017 | ino = parent_sd->s_ino; |
1016 | if (filldir(dirent, "..", 2, filp->f_pos, ino, DT_DIR) == 0) | 1018 | if (filldir(dirent, "..", 2, filp->f_pos, ino, DT_DIR) == 0) |
1017 | filp->f_pos++; | 1019 | filp->f_pos++; |
1020 | else | ||
1021 | return 0; | ||
1018 | } | 1022 | } |
1019 | mutex_lock(&sysfs_mutex); | 1023 | mutex_lock(&sysfs_mutex); |
1020 | for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos); | 1024 | for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos); |
@@ -1045,10 +1049,21 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
1045 | return 0; | 1049 | return 0; |
1046 | } | 1050 | } |
1047 | 1051 | ||
1052 | static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence) | ||
1053 | { | ||
1054 | struct inode *inode = file_inode(file); | ||
1055 | loff_t ret; | ||
1056 | |||
1057 | mutex_lock(&inode->i_mutex); | ||
1058 | ret = generic_file_llseek(file, offset, whence); | ||
1059 | mutex_unlock(&inode->i_mutex); | ||
1060 | |||
1061 | return ret; | ||
1062 | } | ||
1048 | 1063 | ||
1049 | const struct file_operations sysfs_dir_operations = { | 1064 | const struct file_operations sysfs_dir_operations = { |
1050 | .read = generic_read_dir, | 1065 | .read = generic_read_dir, |
1051 | .readdir = sysfs_readdir, | 1066 | .readdir = sysfs_readdir, |
1052 | .release = sysfs_dir_release, | 1067 | .release = sysfs_dir_release, |
1053 | .llseek = generic_file_llseek, | 1068 | .llseek = sysfs_dir_llseek, |
1054 | }; | 1069 | }; |
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 8d924b5ec733..afd83273e6ce 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/magic.h> | 20 | #include <linux/magic.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/user_namespace.h> | ||
22 | 23 | ||
23 | #include "sysfs.h" | 24 | #include "sysfs.h" |
24 | 25 | ||
@@ -111,6 +112,9 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type, | |||
111 | struct super_block *sb; | 112 | struct super_block *sb; |
112 | int error; | 113 | int error; |
113 | 114 | ||
115 | if (!(flags & MS_KERNMOUNT) && !current_user_ns()->may_mount_sysfs) | ||
116 | return ERR_PTR(-EPERM); | ||
117 | |||
114 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 118 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
115 | if (!info) | 119 | if (!info) |
116 | return ERR_PTR(-ENOMEM); | 120 | return ERR_PTR(-ENOMEM); |