Commit 36231d25 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "The sget() one is a long-standing bug and will need to go into -stable
  (in fact, it had been originally caught in RHEL6), the other two are
  3.11-only"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  vfs: constify dentry parameter in d_count()
  livelock avoidance in sget()
  allow O_TMPFILE to work with O_WRONLY
parents 19bf1c2c 24924a20
...@@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o ...@@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
if ((flags & O_TMPFILE_MASK) != O_TMPFILE) if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
return -EINVAL; return -EINVAL;
acc_mode = MAY_OPEN | ACC_MODE(flags); acc_mode = MAY_OPEN | ACC_MODE(flags);
if (!(acc_mode & MAY_WRITE))
return -EINVAL;
} else if (flags & O_PATH) { } else if (flags & O_PATH) {
/* /*
* If we have O_PATH in the open flag. Then we * If we have O_PATH in the open flag. Then we
......
...@@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super); ...@@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super);
* and want to turn it into a full-blown active reference. grab_super() * and want to turn it into a full-blown active reference. grab_super()
* is called with sb_lock held and drops it. Returns 1 in case of * is called with sb_lock held and drops it. Returns 1 in case of
* success, 0 if we had failed (superblock contents was already dead or * success, 0 if we had failed (superblock contents was already dead or
* dying when grab_super() had been called). * dying when grab_super() had been called). Note that this is only
* called for superblocks not in rundown mode (== ones still on ->fs_supers
* of their type), so increment of ->s_count is OK here.
*/ */
static int grab_super(struct super_block *s) __releases(sb_lock) static int grab_super(struct super_block *s) __releases(sb_lock)
{ {
if (atomic_inc_not_zero(&s->s_active)) {
spin_unlock(&sb_lock);
return 1;
}
/* it's going away */
s->s_count++; s->s_count++;
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
/* wait for it to die */
down_write(&s->s_umount); down_write(&s->s_umount);
if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) {
put_super(s);
return 1;
}
up_write(&s->s_umount); up_write(&s->s_umount);
put_super(s); put_super(s);
return 0; return 0;
...@@ -463,11 +463,6 @@ struct super_block *sget(struct file_system_type *type, ...@@ -463,11 +463,6 @@ struct super_block *sget(struct file_system_type *type,
destroy_super(s); destroy_super(s);
s = NULL; s = NULL;
} }
down_write(&old->s_umount);
if (unlikely(!(old->s_flags & MS_BORN))) {
deactivate_locked_super(old);
goto retry;
}
return old; return old;
} }
} }
...@@ -660,10 +655,10 @@ struct super_block *get_active_super(struct block_device *bdev) ...@@ -660,10 +655,10 @@ struct super_block *get_active_super(struct block_device *bdev)
if (hlist_unhashed(&sb->s_instances)) if (hlist_unhashed(&sb->s_instances))
continue; continue;
if (sb->s_bdev == bdev) { if (sb->s_bdev == bdev) {
if (grab_super(sb)) /* drops sb_lock */ if (!grab_super(sb))
return sb;
else
goto restart; goto restart;
up_write(&sb->s_umount);
return sb;
} }
} }
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
......
...@@ -324,7 +324,7 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq) ...@@ -324,7 +324,7 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
return ret; return ret;
} }
static inline unsigned d_count(struct dentry *dentry) static inline unsigned d_count(const struct dentry *dentry)
{ {
return dentry->d_count; return dentry->d_count;
} }
......
...@@ -89,8 +89,8 @@ ...@@ -89,8 +89,8 @@
#endif #endif
/* a horrid kludge trying to make sure that this will fail on old kernels */ /* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR) #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE) #define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
#ifndef O_NDELAY #ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK #define O_NDELAY O_NONBLOCK
......
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