btrfs: fix removed dentries still existing after log is synced
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix removed dentries still existing after log is synced
When we move one inode from one directory to another and both the inode and its previous parent directory were logged before, we are not supposed to have the dentry for the old parent if we have a power failure after the log is synced. Only the new dentry is supposed to exist.
Generally this works correctly, however there is a scenario where this is not currently working, because the old parent of the file/directory that was moved is not authoritative for a range that includes the dir index and dir item keys of the old dentry. This case is better explained with the following example and reproducer:
# The test requires a very specific layout of keys and items in the # fs/subvolume btree to trigger the bug. So we want to make sure that # on whatever platform we are, we have the same leaf/node size. # # Currently in btrfs the node/leaf size can not be smaller than the page # size (but it can be greater than the page size). So use the largest # supported node/leaf size (64K).
$ mkfs.btrfs -f -n 65536 /dev/sdc $ mount /dev/sdc /mnt
# "testdir" is inode 257. $ mkdir /mnt/testdir $ chmod 755 /mnt/testdir
# Create several empty files to have the directory "testdir" with its # items spread over several leaves (7 in this case). $ for ((i = 1; i <= 1200; i++)); do echo -n > /mnt/testdir/file$i done
From the CVE record · Linux
The Linux kernel’s btrfs logging can leave a removed directory entry in place after a move and a power failure following log sync. The described case requires a specific filesystem layout and prior logging of both the moved inode and its old parent directory. It involves local filesystem operations; the input does not identify an authentication requirement beyond the ability to perform those operations.
Engineers running Linux with btrfs should check their kernels; affected versions are not specified.