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.
Unified · Split
| @@ -1290,6 +1290,15 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, · 1289 unmodified lines | |||
| 1290 | * are limited to own subvolumes only | 1290 | * are limited to own subvolumes only |
| 1291 | */ | 1291 | */ |
| 1292 | ret = -EPERM; | 1292 | 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; | ||
| 1293 | } else { | 1302 | } else { |
| 1294 | ret = btrfs_mksnapshot(&file->f_path, idmap, | 1303 | ret = btrfs_mksnapshot(&file->f_path, idmap, |
| 1295 | name, namelen, | 1304 | name, namelen, |