History

btrfs: do not allow non subvolume root targets for snapshot

Our btrfs subvolume snapshot <source> <destination> utility enforces that <source> is the root of the subvolume, however this isn't enforced in the kernel. Update the kernel to also enforce this limitation to avoid problems with other users of this ioctl that don't have the appropriate checks in place.

Josef Bacik committed 2 years ago

Commit a8892fd1 parent e85a0ad1 file · +9 −0Browse files

Unified · Split

fs/btrfs/ioctl.c+9−0
@@ -1290,6 +1290,15 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, · 1289 unmodified lines
12901290 * are limited to own subvolumes only
12911291 */
12921292 ret = -EPERM;
1293+ } else if (btrfs_ino(BTRFS_I(src_inode)) != BTRFS_FIRST_FREE_OBJECTID) {
1294+ /*
1295+ * Snapshots must be made with the src_inode referring
1296+ * to the subvolume inode, otherwise the permission
1297+ * checking above is useless because we may have
1298+ * permission on a lower directory but not the subvol
1299+ * itself.
1300+ */
1301+ ret = -EINVAL;
12931302 } else {
12941303 ret = btrfs_mksnapshot(&file->f_path, idmap,
12951304 name, namelen,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t