Commit dbd8132a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'vfs-6.10-rc7.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs fixes from Christian Brauner:
 "VFS:

   - Improve handling of deep ancestor chains in is_subdir()

   - Release locks cleanly when fctnl_setlk() races with close().

     When setting a file lock fails the VFS tries to cleanup the already
     created lock. The helper used for this calls back into the LSM
     layer which may cause it to fail, leaving the stale lock accessible
     via /proc/locks.

  AFS:

   - Fix a comma/semicolon typo"

* tag 'vfs-6.10-rc7.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  afs: Convert comma to semicolon
  fs: better handle deep ancestor chains in is_subdir()
  filelock: Remove locks reliably when fcntl/close race is detected
parents 73461051 655593a4
...@@ -512,7 +512,7 @@ static int afs_iget5_set_root(struct inode *inode, void *opaque) ...@@ -512,7 +512,7 @@ static int afs_iget5_set_root(struct inode *inode, void *opaque)
struct afs_vnode *vnode = AFS_FS_I(inode); struct afs_vnode *vnode = AFS_FS_I(inode);
vnode->volume = as->volume; vnode->volume = as->volume;
vnode->fid.vid = as->volume->vid, vnode->fid.vid = as->volume->vid;
vnode->fid.vnode = 1; vnode->fid.vnode = 1;
vnode->fid.unique = 1; vnode->fid.unique = 1;
inode->i_ino = 1; inode->i_ino = 1;
...@@ -545,7 +545,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key) ...@@ -545,7 +545,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
BUG_ON(!(inode->i_state & I_NEW)); BUG_ON(!(inode->i_state & I_NEW));
vnode = AFS_FS_I(inode); vnode = AFS_FS_I(inode);
vnode->cb_v_check = atomic_read(&as->volume->cb_v_break), vnode->cb_v_check = atomic_read(&as->volume->cb_v_break);
afs_set_netfs_context(vnode); afs_set_netfs_context(vnode);
op = afs_alloc_operation(key, as->volume); op = afs_alloc_operation(key, as->volume);
......
...@@ -3029,28 +3029,25 @@ EXPORT_SYMBOL(d_splice_alias); ...@@ -3029,28 +3029,25 @@ EXPORT_SYMBOL(d_splice_alias);
bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
{ {
bool result; bool subdir;
unsigned seq; unsigned seq;
if (new_dentry == old_dentry) if (new_dentry == old_dentry)
return true; return true;
do { /* Access d_parent under rcu as d_move() may change it. */
/* for restarting inner loop in case of seq retry */ rcu_read_lock();
seq = read_seqbegin(&rename_lock); seq = read_seqbegin(&rename_lock);
/* subdir = d_ancestor(old_dentry, new_dentry);
* Need rcu_readlock to protect against the d_parent trashing /* Try lockless once... */
* due to d_move if (read_seqretry(&rename_lock, seq)) {
*/ /* ...else acquire lock for progress even on deep chains. */
rcu_read_lock(); read_seqlock_excl(&rename_lock);
if (d_ancestor(old_dentry, new_dentry)) subdir = d_ancestor(old_dentry, new_dentry);
result = true; read_sequnlock_excl(&rename_lock);
else }
result = false; rcu_read_unlock();
rcu_read_unlock(); return subdir;
} while (read_seqretry(&rename_lock, seq));
return result;
} }
EXPORT_SYMBOL(is_subdir); EXPORT_SYMBOL(is_subdir);
......
...@@ -2448,8 +2448,9 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2448,8 +2448,9 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
error = do_lock_file_wait(filp, cmd, file_lock); error = do_lock_file_wait(filp, cmd, file_lock);
/* /*
* Attempt to detect a close/fcntl race and recover by releasing the * Detect close/fcntl races and recover by zapping all POSIX locks
* lock that was just acquired. There is no need to do that when we're * associated with this file and our files_struct, just like on
* filp_flush(). There is no need to do that when we're
* unlocking though, or for OFD locks. * unlocking though, or for OFD locks.
*/ */
if (!error && file_lock->c.flc_type != F_UNLCK && if (!error && file_lock->c.flc_type != F_UNLCK &&
...@@ -2464,9 +2465,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2464,9 +2465,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
f = files_lookup_fd_locked(files, fd); f = files_lookup_fd_locked(files, fd);
spin_unlock(&files->file_lock); spin_unlock(&files->file_lock);
if (f != filp) { if (f != filp) {
file_lock->c.flc_type = F_UNLCK; locks_remove_posix(filp, files);
error = do_lock_file_wait(filp, cmd, file_lock);
WARN_ON_ONCE(error);
error = -EBADF; error = -EBADF;
} }
} }
......
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