[GIT PULL] vfs: rename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Linus,

/* Summary */
This contains the work from Jan to fix problems with cross-directory
renames originally reported in [1].

To quickly sum it up some filesystems (so far we know at least about
ext4, udf, f2fs, ocfs2, likely also reiserfs, gfs2 and others) need to
lock the directory when it is being renamed into another directory.

This is because we need to update the parent pointer in the directory in
that case and if that races with other operations on the directory, in
particular a conversion from one directory format into another, bad
things can happen.

So far we've done the locking in the filesystem code but recently
Darrick pointed out in [2] that the RENAME_EXCHANGE case was missing.
That one is particularly nasty because RENAME_EXCHANGE can arbitrarily
mix regular files and directories and proper lock ordering is not
achievable in the filesystems alone.

This patch set adds locking into vfs_rename() so that not only parent
directories but also moved inodes, regardless of whether they are
directories or not, are locked when calling into the filesystem.

This means establishing a locking order for unrelated directories. New
helpers are added for this purpose and our documentation is updated to
cover this in detail.

The locking is now actually easier to follow as we now always lock
source and target. We've always locked the target independent of whether
it was a directory or file and we've always locked source if it was a
regular file. The exact details for why this came about can be found in
[3] and [4].

Link: https://lore.kernel.org/all/20230117123735.un7wbamlbdihninm@quack3 [1]
Link: https://lore.kernel.org/all/20230517045836.GA11594@frogsfrogsfrogs [2]
Link: https://lore.kernel.org/all/20230526-schrebergarten-vortag-9cd89694517e@brauner [3]
Link: https://lore.kernel.org/all/20230530-seenotrettung-allrad-44f4b00139d4@brauner [4]

/* Testing */
clang: Ubuntu clang version 15.0.7
gcc: (Ubuntu 12.2.0-3ubuntu1) 12.2.0

All patches are based on v6.4-rc2 and have been sitting in linux-next.
No build failures or warnings were observed. All old and new tests in
fstests, selftests, and LTP pass without regressions.

/* Conflicts */
At the time of creating this PR no merge conflicts were reported from
linux-next and no merge conflicts showed up doing a test-merge with
current mainline.

The following changes since commit f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6:

  Linux 6.4-rc2 (2023-05-14 12:51:40 -0700)

are available in the Git repository at:

  git@xxxxxxxxxxxxxxxxxxx:pub/scm/linux/kernel/git/vfs/vfs tags/v6.5/vfs.rename.locking

for you to fetch changes up to 2454ad83b90afbc6ed2c22ec1310b624c40bf0d3:

  fs: Restrict lock_two_nondirectories() to non-directory inodes (2023-06-07 09:15:11 +0200)

Please consider pulling these changes from the signed v6.5/vfs.rename.locking tag.

Thanks!
Christian

----------------------------------------------------------------
v6.5/vfs.rename.locking

----------------------------------------------------------------
Jan Kara (6):
      ext4: Remove ext4 locking of moved directory
      Revert "udf: Protect rename against modification of moved directory"
      Revert "f2fs: fix potential corruption when moving a directory"
      fs: Establish locking order for unrelated directories
      fs: Lock moved directories
      fs: Restrict lock_two_nondirectories() to non-directory inodes

 Documentation/filesystems/directory-locking.rst | 26 ++++++-----
 fs/ext4/namei.c                                 | 17 +------
 fs/f2fs/namei.c                                 | 16 +------
 fs/inode.c                                      | 62 +++++++++++++++++++++----
 fs/internal.h                                   |  2 +
 fs/namei.c                                      | 26 +++++++----
 fs/udf/namei.c                                  | 14 +-----
 7 files changed, 89 insertions(+), 74 deletions(-)



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux