btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ be6e8dc0ba84029997075a1ec77b4ddb863cbe15 · < 361d67276eb8ec6be8f27f4ad6c6090459438fee| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
The function btrfs_encode_fh() does not properly account for the three cases it handles.
Before writing to the file handle (fh), the function only returns to the user BTRFS_FID_SIZE_NON_CONNECTABLE (5 dwords, 20 bytes) or BTRFS_FID_SIZE_CONNECTABLE (8 dwords, 32 bytes).
However, when a parent exists and the root ID of the parent and the inode are different, the function writes BTRFS_FID_SIZE_CONNECTABLE_ROOT (10 dwords, 40 bytes).
If *max_len is not large enough, this write goes out of bounds because BTRFS_FID_SIZE_CONNECTABLE_ROOT is greater than BTRFS_FID_SIZE_CONNECTABLE originally returned.
This results in an 8-byte out-of-bounds write at fid->parent_root_objectid = parent_root_id.
A previous attempt to fix this issue was made but was lost.
From the CVE record · Linux
The Linux kernel’s btrfs_encode_fh() can write eight bytes out of bounds when a parent exists, its root ID differs from the inode’s, and the supplied file-handle buffer is too small. This could corrupt memory, but the input does not establish how an attacker could trigger it or whether access or user interaction is required.
Engineers running Linux kernels with btrfs should check their kernels; affected versions are not specified.