linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] fs: Fix directory corruption when moving directories
@ 2023-06-01 10:58 Jan Kara
  2023-06-01 10:58 ` [PATCH v2 1/6] ext4: Remove ext4 locking of moved directory Jan Kara
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Jan Kara @ 2023-06-01 10:58 UTC (permalink / raw)
  To: Al Viro
  Cc: linux-fsdevel, Christian Brauner, Miklos Szeredi,
	Darrick J. Wong, Ted Tso, Jaegeuk Kim, linux-ext4, linux-xfs,
	linux-f2fs-devel, Jan Kara

Hello,

this patch set fixes a problem 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 operation 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 [2] that we've missed the RENAME_EXCHANGE case in our ext4 fix.
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 whether they are directories or
not) are locked when calling into the filesystem.

Changes since v1:
* Made sure lock_two_inodes() uses subclass1 for the obtained lock in case
  there is only one inode locked
* Fixes unlocked_two_nondirectories() to properly unlock inodes even if
  directories are accidentally passed in.

								Honza

[1] https://lore.kernel.org/all/20230117123735.un7wbamlbdihninm@quack3
[2] https://lore.kernel.org/all/20230517045836.GA11594@frogsfrogsfrogs

Previous versions:
Link: http://lore.kernel.org/r/20230525100654.15069-1-jack@suse.cz # v1

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2023-07-06  0:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01 10:58 [PATCH v2 0/6] fs: Fix directory corruption when moving directories Jan Kara
2023-06-01 10:58 ` [PATCH v2 1/6] ext4: Remove ext4 locking of moved directory Jan Kara
2023-06-01 14:52   ` Theodore Ts'o
2023-06-01 15:27     ` Jan Kara
2023-06-01 15:58       ` Christian Brauner
2023-06-01 10:58 ` [PATCH v2 2/6] Revert "udf: Protect rename against modification of moved directory" Jan Kara
2023-06-01 10:58 ` [PATCH v2 3/6] Revert "f2fs: fix potential corruption when moving a directory" Jan Kara
2023-06-01 10:58 ` [PATCH v2 4/6] fs: Establish locking order for unrelated directories Jan Kara
2023-06-01 13:58   ` Christian Brauner
2023-06-01 15:24     ` Jan Kara
2023-06-01 15:37       ` David Laight
2023-06-01 16:13         ` Jan Kara
2023-06-01 16:21           ` Christian Brauner
2023-06-01 16:33           ` David Laight
2023-06-02 12:34             ` Christian Brauner
2023-06-01 15:59       ` Christian Brauner
2023-06-02  1:36   ` kernel test robot
2023-06-01 10:58 ` [PATCH v2 5/6] fs: Lock moved directories Jan Kara
2023-06-01 10:58 ` [PATCH v2 6/6] fs: Restrict lock_two_nondirectories() to non-directory inodes Jan Kara
2023-06-02 13:05 ` [PATCH v2 0/6] fs: Fix directory corruption when moving directories Christian Brauner
2023-07-06  0:18 ` [f2fs-dev] " patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).