Commit 3751c970 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'driver-core-3.14-rc5' of...

Merge tag 'driver-core-3.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull sysfs fix from Greg KH:
 "Here is a single sysfs fix for 3.14-rc5.  It fixes a reported problem
  with the namespace code in sysfs"

* tag 'driver-core-3.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  sysfs: fix namespace refcnt leak
parents 9ff7aeb6 fed95bab
...@@ -94,6 +94,7 @@ const void *kernfs_super_ns(struct super_block *sb) ...@@ -94,6 +94,7 @@ const void *kernfs_super_ns(struct super_block *sb)
* @fs_type: file_system_type of the fs being mounted * @fs_type: file_system_type of the fs being mounted
* @flags: mount flags specified for the mount * @flags: mount flags specified for the mount
* @root: kernfs_root of the hierarchy being mounted * @root: kernfs_root of the hierarchy being mounted
* @new_sb_created: tell the caller if we allocated a new superblock
* @ns: optional namespace tag of the mount * @ns: optional namespace tag of the mount
* *
* This is to be called from each kernfs user's file_system_type->mount() * This is to be called from each kernfs user's file_system_type->mount()
...@@ -104,7 +105,8 @@ const void *kernfs_super_ns(struct super_block *sb) ...@@ -104,7 +105,8 @@ const void *kernfs_super_ns(struct super_block *sb)
* The return value can be passed to the vfs layer verbatim. * The return value can be passed to the vfs layer verbatim.
*/ */
struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
struct kernfs_root *root, const void *ns) struct kernfs_root *root, bool *new_sb_created,
const void *ns)
{ {
struct super_block *sb; struct super_block *sb;
struct kernfs_super_info *info; struct kernfs_super_info *info;
...@@ -122,6 +124,10 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, ...@@ -122,6 +124,10 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
kfree(info); kfree(info);
if (IS_ERR(sb)) if (IS_ERR(sb))
return ERR_CAST(sb); return ERR_CAST(sb);
if (new_sb_created)
*new_sb_created = !sb->s_root;
if (!sb->s_root) { if (!sb->s_root) {
error = kernfs_fill_super(sb); error = kernfs_fill_super(sb);
if (error) { if (error) {
......
...@@ -27,6 +27,7 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type, ...@@ -27,6 +27,7 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
{ {
struct dentry *root; struct dentry *root;
void *ns; void *ns;
bool new_sb;
if (!(flags & MS_KERNMOUNT)) { if (!(flags & MS_KERNMOUNT)) {
if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type)) if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
...@@ -37,8 +38,8 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type, ...@@ -37,8 +38,8 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
} }
ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
root = kernfs_mount_ns(fs_type, flags, sysfs_root, ns); root = kernfs_mount_ns(fs_type, flags, sysfs_root, &new_sb, ns);
if (IS_ERR(root)) if (IS_ERR(root) || !new_sb)
kobj_ns_drop(KOBJ_NS_TYPE_NET, ns); kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
return root; return root;
} }
......
...@@ -249,7 +249,8 @@ void kernfs_notify(struct kernfs_node *kn); ...@@ -249,7 +249,8 @@ void kernfs_notify(struct kernfs_node *kn);
const void *kernfs_super_ns(struct super_block *sb); const void *kernfs_super_ns(struct super_block *sb);
struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
struct kernfs_root *root, const void *ns); struct kernfs_root *root, bool *new_sb_created,
const void *ns);
void kernfs_kill_sb(struct super_block *sb); void kernfs_kill_sb(struct super_block *sb);
void kernfs_init(void); void kernfs_init(void);
...@@ -317,7 +318,7 @@ static inline const void *kernfs_super_ns(struct super_block *sb) ...@@ -317,7 +318,7 @@ static inline const void *kernfs_super_ns(struct super_block *sb)
static inline struct dentry * static inline struct dentry *
kernfs_mount_ns(struct file_system_type *fs_type, int flags, kernfs_mount_ns(struct file_system_type *fs_type, int flags,
struct kernfs_root *root, const void *ns) struct kernfs_root *root, bool *new_sb_created, const void *ns)
{ return ERR_PTR(-ENOSYS); } { return ERR_PTR(-ENOSYS); }
static inline void kernfs_kill_sb(struct super_block *sb) { } static inline void kernfs_kill_sb(struct super_block *sb) { }
...@@ -368,9 +369,9 @@ static inline int kernfs_remove_by_name(struct kernfs_node *parent, ...@@ -368,9 +369,9 @@ static inline int kernfs_remove_by_name(struct kernfs_node *parent,
static inline struct dentry * static inline struct dentry *
kernfs_mount(struct file_system_type *fs_type, int flags, kernfs_mount(struct file_system_type *fs_type, int flags,
struct kernfs_root *root) struct kernfs_root *root, bool *new_sb_created)
{ {
return kernfs_mount_ns(fs_type, flags, root, NULL); return kernfs_mount_ns(fs_type, flags, root, new_sb_created, NULL);
} }
#endif /* __LINUX_KERNFS_H */ #endif /* __LINUX_KERNFS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment