{
    "dataType": "CVE_RECORD",
    "dataVersion": "5.2",
    "cveMetadata": {
        "cveId": "CVE-2023-54121",
        "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "state": "PUBLISHED",
        "assignerShortName": "Linux",
        "dateReserved": "2025-12-24T13:02:52.520Z",
        "datePublished": "2025-12-24T13:06:41.185Z",
        "dateUpdated": "2026-08-05T09:17:24.043Z"
    },
    "containers": {
        "cna": {
            "providerMetadata": {
                "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
                "shortName": "Linux",
                "dateUpdated": "2026-08-05T09:17:24.043Z"
            },
            "descriptions": [
                {
                    "lang": "en",
                    "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix incorrect splitting in btrfs_drop_extent_map_range\n\nIn production we were seeing a variety of WARN_ON()'s in the extent_map\ncode, specifically in btrfs_drop_extent_map_range() when we have to call\nadd_extent_mapping() for our second split.\n\nConsider the following extent map layout\n\n\tPINNED\n\t[0 16K)  [32K, 48K)\n\nand then we call btrfs_drop_extent_map_range for [0, 36K), with\nskip_pinned == true.  The initial loop will have\n\n\tstart = 0\n\tend = 36K\n\tlen = 36K\n\nwe will find the [0, 16k) extent, but since we are pinned we will skip\nit, which has this code\n\n\tstart = em_end;\n\tif (end != (u64)-1)\n\t\tlen = start + len - em_end;\n\nem_end here is 16K, so now the values are\n\n\tstart = 16K\n\tlen = 16K + 36K - 16K = 36K\n\nlen should instead be 20K.  This is a problem when we find the next\nextent at [32K, 48K), we need to split this extent to leave [36K, 48k),\nhowever the code for the split looks like this\n\n\tsplit->start = start + len;\n\tsplit->len = em_end - (start + len);\n\nIn this case we have\n\n\tem_end = 48K\n\tsplit->start = 16K + 36K       // this should be 16K + 20K\n\tsplit->len = 48K - (16K + 36K) // this overflows as 16K + 36K is 52K\n\nand now we have an invalid extent_map in the tree that potentially\noverlaps other entries in the extent map.  Even in the non-overlapping\ncase we will have split->start set improperly, which will cause problems\nwith any block related calculations.\n\nWe don't actually need len in this loop, we can simply use end as our\nend point, and only adjust start up when we find a pinned extent we need\nto skip.\n\nAdjust the logic to do this, which keeps us from inserting an invalid\nextent map.\n\nWe only skip_pinned in the relocation case, so this is relatively rare,\nexcept in the case where you are running relocation a lot, which can\nhappen with auto relocation on."
                }
            ],
            "metrics": [
                {
                    "cvssV3_1": {
                        "version": "3.1",
                        "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
                        "baseScore": 7.8,
                        "baseSeverity": "HIGH"
                    },
                    "scenarios": [
                        {
                            "lang": "en",
                            "value": "AV:L - The bug is triggered through local filesystem operations on a mounted btrfs — ordinary writes creating pinned extent maps combined with the in-kernel relocation path. No network or remote peer data is involved.\nAC:L - The attacker fully controls the extent-map layout side (writes create EXTENT_FLAG_PINNED maps via create_io_em(), and file layout/extent sizes are attacker-chosen) and can maintain it continuously; relocation recurs automatically on zoned btrfs (bg_reclaim_threshold=75 by default, drivable by filling then deleting data) and via routine distro balance timers, so no condition is genuinely outside attacker influence.\nPR:L - The attacker's side of the trigger requires only an unprivileged local account with write access to a btrfs filesystem — plain write(2)/fallocate paths with no capability check reach create_io_em() and the extent map tree. No CAP_SYS_ADMIN is needed on the attacker's own path.\nUI:N - No victim action is required — automatic block-group reclaim and scheduled relocation run as background kernel work, and the corrupting split happens without any interactive step by another user.\nS:U - The corruption is confined to the kernel's own extent map tree and the filesystem it manages; no VM, IOMMU, or sandbox security boundary is crossed.\nC:H - The inserted extent map carries a wrong block_start (off by the skipped pinned extent's size) and an underflowed length, and the resulting extent_offset underflow in btrfs_do_readpage() makes disk_bytenr point at attacker-influenced wrong logical addresses, pulling other files' on-disk data into the attacker's page cache.\nI:H - The same bogus block_start/block_len feed the writeback and direct-I/O paths, so data can be written to disk locations belonging to other files, and the em rbtree ordering invariant is violated (extent_map_end wraps below start), propagating further corruption through merge_extent_mapping().\nA:H - Production-observed WARN_ON()s in add_extent_mapping(), ASSERT(ret == 0) which is a BUG() with CONFIG_BTRFS_ASSERT, u64 length underflow to ~2^64, and inconsistent extent map trees leading to transaction abort and forced read-only remount or panic on panic_on_warn systems."
                        }
                    ]
                }
            ],
            "affected": [
                {
                    "product": "Linux",
                    "vendor": "Linux",
                    "defaultStatus": "unaffected",
                    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
                    "programFiles": [
                        "fs/btrfs/extent_map.c"
                    ],
                    "versions": [
                        {
                            "version": "55ef68990029fcd8d04d42fc184aa7fb18cf309e",
                            "lessThan": "9f68e2105dd96cf0fafffffafb2337fbd0fbae1f",
                            "status": "affected",
                            "versionType": "git"
                        },
                        {
                            "version": "55ef68990029fcd8d04d42fc184aa7fb18cf309e",
                            "lessThan": "b43a4c99d878cf5e59040e45c96bb0a8358bfb3b",
                            "status": "affected",
                            "versionType": "git"
                        },
                        {
                            "version": "55ef68990029fcd8d04d42fc184aa7fb18cf309e",
                            "lessThan": "c962098ca4af146f2625ed64399926a098752c9c",
                            "status": "affected",
                            "versionType": "git"
                        },
                        {
                            "version": "c87afd35a28b2661a2626a1b28e9fd69adcad9f9",
                            "status": "affected",
                            "versionType": "git"
                        },
                        {
                            "version": "2.6.32.19",
                            "lessThan": "2.6.33",
                            "status": "affected",
                            "versionType": "semver"
                        }
                    ]
                },
                {
                    "product": "Linux",
                    "vendor": "Linux",
                    "defaultStatus": "affected",
                    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
                    "programFiles": [
                        "fs/btrfs/extent_map.c"
                    ],
                    "versions": [
                        {
                            "version": "2.6.33",
                            "status": "affected"
                        },
                        {
                            "version": "0",
                            "lessThan": "2.6.33",
                            "status": "unaffected",
                            "versionType": "semver"
                        },
                        {
                            "version": "6.1.47",
                            "lessThanOrEqual": "6.1.*",
                            "status": "unaffected",
                            "versionType": "semver"
                        },
                        {
                            "version": "6.4.12",
                            "lessThanOrEqual": "6.4.*",
                            "status": "unaffected",
                            "versionType": "semver"
                        },
                        {
                            "version": "6.5",
                            "lessThanOrEqual": "*",
                            "status": "unaffected",
                            "versionType": "original_commit_for_fix"
                        }
                    ]
                }
            ],
            "cpeApplicability": [
                {
                    "nodes": [
                        {
                            "operator": "OR",
                            "negate": false,
                            "cpeMatch": [
                                {
                                    "vulnerable": true,
                                    "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                                    "versionStartIncluding": "2.6.33",
                                    "versionEndExcluding": "6.1.47"
                                },
                                {
                                    "vulnerable": true,
                                    "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                                    "versionStartIncluding": "2.6.33",
                                    "versionEndExcluding": "6.4.12"
                                },
                                {
                                    "vulnerable": true,
                                    "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                                    "versionStartIncluding": "2.6.33",
                                    "versionEndExcluding": "6.5"
                                },
                                {
                                    "vulnerable": true,
                                    "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                                    "versionStartIncluding": "2.6.32.19"
                                }
                            ]
                        }
                    ]
                }
            ],
            "references": [
                {
                    "url": "https://git.kernel.org/stable/c/9f68e2105dd96cf0fafffffafb2337fbd0fbae1f"
                },
                {
                    "url": "https://git.kernel.org/stable/c/b43a4c99d878cf5e59040e45c96bb0a8358bfb3b"
                },
                {
                    "url": "https://git.kernel.org/stable/c/c962098ca4af146f2625ed64399926a098752c9c"
                }
            ],
            "title": "btrfs: fix incorrect splitting in btrfs_drop_extent_map_range",
            "x_generator": {
                "engine": "bippy-1.2.0"
            }
        }
    }
}