Skip to content

Commit d6d09a6

Browse files
committed
Merge tag 'for-5.14-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fix from David Sterba: "One more fix for cross-rename, adding a missing check for directory and subvolume, this could lead to a crash" * tag 'for-5.14-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: prevent rename2 from exchanging a subvol with a directory from different parents
2 parents 01f15f3 + 3f79f6f commit d6d09a6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/btrfs/inode.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9226,8 +9226,14 @@ static int btrfs_rename_exchange(struct inode *old_dir,
92269226
bool dest_log_pinned = false;
92279227
bool need_abort = false;
92289228

9229-
/* we only allow rename subvolume link between subvolumes */
9230-
if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest)
9229+
/*
9230+
* For non-subvolumes allow exchange only within one subvolume, in the
9231+
* same inode namespace. Two subvolumes (represented as directory) can
9232+
* be exchanged as they're a logical link and have a fixed inode number.
9233+
*/
9234+
if (root != dest &&
9235+
(old_ino != BTRFS_FIRST_FREE_OBJECTID ||
9236+
new_ino != BTRFS_FIRST_FREE_OBJECTID))
92319237
return -EXDEV;
92329238

92339239
/* close the race window with snapshot create/destroy ioctl */

0 commit comments

Comments
 (0)