{"schemaVersion":1,"url":"https://cve.openhack.com/cve/CVE-2023-53143","id":"CVE-2023-53143","title":"ext4: fix another off-by-one fsmap error on 1k block filesystems","description":"In the Linux kernel, the following vulnerability has been resolved:\n\next4: fix another off-by-one fsmap error on 1k block filesystems\n\nApparently syzbot figured out that issuing this FSMAP call:\n\nstruct fsmap_head cmd = {\n\t.fmh_count\t= ...;\n\t.fmh_keys\t= {\n\t\t{ .fmr_device = /* ext4 dev */, .fmr_physical = 0, },\n\t\t{ .fmr_device = /* ext4 dev */, .fmr_physical = 0, },\n\t},\n...\n};\nret = ioctl(fd, FS_IO","descriptionLong":"In the Linux kernel, the following vulnerability has been resolved:\n\next4: fix another off-by-one fsmap error on 1k block filesystems\n\nApparently syzbot figured out that issuing this FSMAP call:\n\nstruct fsmap_head cmd = {\n\t.fmh_count\t= ...;\n\t.fmh_keys\t= {\n\t\t{ .fmr_device = /* ext4 dev */, .fmr_physical = 0, },\n\t\t{ .fmr_device = /* ext4 dev */, .fmr_physical = 0, },\n\t},\n...\n};\nret = ioctl(fd, FS_IOC_GETFSMAP, &cmd);\n\nProduces this crash if the underlying filesystem is a 1k-block ext4\nfilesystem:\n\nkernel BUG at fs/ext4/ext4.h:3331!\ninvalid opcode: 0000 [#1] PREEMPT SMP\nCPU: 3 PID: 3227965 Comm: xfs_io Tainted: G        W  O       6.2.0-rc8-achx\nHardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014\nRIP: 0010:ext4_mb_load_buddy_gfp+0x47c/0x570 [ext4]\nRSP: 0018:ffffc90007c03998 EFLAGS: 00010246\nRAX: ffff888004978000 RBX: ffffc90007c03a20 RCX: ffff888041618000\nRDX: 0000000000000000 RSI: 00000000000005a4 RDI: ffffffffa0c99b11\nRBP: ffff888012330000 R08: ffffffffa0c2b7d0 R09: 0000000000000400\nR10: ffffc90007c03950 R11: 0000000000000000 R12: 0000000000000001\nR13: 00000000ffffffff R14: 0000000000000c40 R15: ffff88802678c398\nFS:  00007fdf2020c880(0000) GS:ffff88807e100000(0000) knlGS:0000000000000000\nCS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033\nCR2: 00007ffd318a5fe8 CR3: 000000007f80f001 CR4: 00000000001706e0\nCall Trace:\n <TASK>\n ext4_mballoc_query_range+0x4b/0x210 [ext4 dfa189daddffe8fecd3cdfd00564e0f265a8ab80]\n ext4_getfsmap_datadev+0x713/0x890 [ext4 dfa189daddffe8fecd3cdfd00564e0f265a8ab80]\n ext4_getfsmap+0x2b7/0x330 [ext4 dfa189daddffe8fecd3cdfd00564e0f265a8ab80]\n ext4_ioc_getfsmap+0x153/0x2b0 [ext4 dfa189daddffe8fecd3cdfd00564e0f265a8ab80]\n __ext4_ioctl+0x2a7/0x17e0 [ext4 dfa189daddffe8fecd3cdfd00564e0f265a8ab80]\n __x64_sys_ioctl+0x82/0xa0\n do_syscall_64+0x2b/0x80\n entry_SYSCALL_64_after_hwframe+0x46/0xb0\nRIP: 0033:0x7fdf20558aff\nRSP: 002b:00007ffd318a9e30 EFLAGS: 00000246 ORIG_RAX: 0000000000000010\nRAX: ffffffffffffffda RBX: 00000000000200c0 RCX: 00007fdf20558aff\nRDX: 00007fdf1feb2010 RSI: 00000000c0c0583b RDI: 0000000000000003\nRBP: 00005625c0634be0 R08: 00005625c0634c40 R09: 0000000000000001\nR10: 0000000000000000 R11: 0000000000000246 R12: 00007fdf1feb2010\nR13: 00005625be70d994 R14: 0000000000000800 R15: 0000000000000000\n\nFor GETFSMAP calls, the caller selects a physical block device by\nwriting its block number into fsmap_head.fmh_keys[01].fmr_device.\nTo query mappings for a subrange of the device, the starting byte of the\nrange is written to fsmap_head.fmh_keys[0].fmr_physical and the last\nbyte of the range goes in fsmap_head.fmh_keys[1].fmr_physical.\n\nIOWs, to query what mappings overlap with bytes 3-14 of /dev/sda, you'd\nset the inputs as follows:\n\n\tfmh_keys[0] = { .fmr_device = major(8, 0), .fmr_physical = 3},\n\tfmh_keys[1] = { .fmr_device = major(8, 0), .fmr_physical = 14},\n\nWhich would return you whatever is mapped in the 12 bytes starting at\nphysical offset 3.\n\nThe crash is due to insufficient range validation of keys[1] in\next4_getfsmap_datadev.  On 1k-block filesystems, block 0 is not part of\nthe filesystem, which means that s_first_data_block is nonzero.\next4_get_group_no_and_offset subtracts this quantity from the blocknr\nargument before cracking it into a group number and a block number\nwithin a group.  IOWs, block group 0 spans blocks 1-8192 (1-based)\ninstead of 0-8191 (0-based) like what happens with larger blocksizes.\n\nThe net result of this encoding is that blocknr < s_first_data_block is\nnot a valid input to this function.  The end_fsb variable is set from\nthe keys that are copied from userspace, which means that in the above\nexample, its value is zero.  That leads to an underflow here:\n\n\tblocknr = blocknr - le32_to_cpu(es->s_first_data_block);\n\nThe division then operates on -1:\n\n\toffset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb)) >>\n\t\tEXT4_SB(sb)->s_cluster_bits;\n\nLeaving an impossibly large group number (2^32-1) in blocknr.\next4_getfsmap_check_keys checked that keys[0\n---truncated---","published":"2025-05-02T15:56:13.656Z","updated":"2026-10-28T02:30:30.999124124Z","reserved":"2025-05-02T15:51:43.564Z","status":"Analyzed","rejected":false,"assigner":"Linux","metric":{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","rating":"medium","source":"NVD"},"metrics":[{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","rating":"medium","source":"NVD"}],"rating":"medium","products":["Linux"],"affectedProducts":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"a70b49dc7eee5dbe3775a650ce598e3557ff5475","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"f16054ac1774915160ca4e1c73ff7a269465a1b9","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"c24f838493792b5e78a3596b4ca96375aa0af4c2","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"1d2366624b4c19a2ba6baf67fe57f4a1b0f67c05","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"c5d7c31e17224d847a330180ec1b03bf390632b2","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"eb3a695aa71a514f2e7f5778e05faba3733b70a0","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"15ebade3266b300da9cd1edce4004fe8fd6a2b88","status":"affected","versionType":"git"},{"version":"4a4956249dac0b9b0027949907bff0cd1a9b57fa","lessThan":"c993799baf9c5861f8df91beb80e1611b12efcbd","status":"affected","versionType":"git"}],"platforms":[]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.13","status":"affected"},{"version":"0","lessThan":"4.13","status":"unaffected","versionType":"semver"},{"version":"4.14.310","lessThanOrEqual":"4.14.*","status":"unaffected","versionType":"semver"},{"version":"4.19.278","lessThanOrEqual":"4.19.*","status":"unaffected","versionType":"semver"},{"version":"5.4.237","lessThanOrEqual":"5.4.*","status":"unaffected","versionType":"semver"},{"version":"5.10.175","lessThanOrEqual":"5.10.*","status":"unaffected","versionType":"semver"},{"version":"5.15.103","lessThanOrEqual":"5.15.*","status":"unaffected","versionType":"semver"},{"version":"6.1.20","lessThanOrEqual":"6.1.*","status":"unaffected","versionType":"semver"},{"version":"6.2.7","lessThanOrEqual":"6.2.*","status":"unaffected","versionType":"semver"},{"version":"6.3","lessThanOrEqual":"*","status":"unaffected","versionType":"original_commit_for_fix"}],"platforms":[]}],"packages":[],"cwes":["CWE-193"],"aliases":[],"references":[{"url":"https://git.kernel.org/stable/c/a70b49dc7eee5dbe3775a650ce598e3557ff5475","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/f16054ac1774915160ca4e1c73ff7a269465a1b9","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/c24f838493792b5e78a3596b4ca96375aa0af4c2","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/1d2366624b4c19a2ba6baf67fe57f4a1b0f67c05","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/c5d7c31e17224d847a330180ec1b03bf390632b2","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/eb3a695aa71a514f2e7f5778e05faba3733b70a0","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/15ebade3266b300da9cd1edce4004fe8fd6a2b88","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/c993799baf9c5861f8df91beb80e1611b12efcbd","tags":["Patch","web"]},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/53xxx/CVE-2023-53143.json","tags":["advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-53143","tags":["advisory"]},{"url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","tags":["package"]}],"patchReferenced":true,"fixAvailable":true,"exploitReferenced":false,"kev":false,"kevAdded":null,"kevDue":null,"kevEntry":null,"ssvc":null,"epss":0.00194,"epssPercentile":0.09188,"sources":[{"name":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2023-53143","ok":true},{"name":"NVD","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-53143","ok":true,"note":"Analyzed"},{"name":"OSV","url":"https://osv.dev/vulnerability/CVE-2023-53143","ok":true,"note":"0 packages"},{"name":"CISA KEV","url":"https://www.cisa.gov/known-exploited-vulnerabilities-catalog","ok":true,"note":"not listed"},{"name":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2023-53143","ok":true,"note":"scored 2026-11-19"}],"aiTitle":false,"tech":[],"critical":[],"attention":null}