CVE-2026-97549: xfs: fix under-reservation of blocks when repairing sf directories
In the Linux kernel, the following vulnerability has been resolved:
xfs: fix under-reservation of blocks when repairing sf directories
Whilst running QA on XFS for-next as of 7.3-rc2 with MKFSOPTIONS="-n size=8192", I observed the following (trimmed) dmesg splat:
XFS: Assertion failed: args->total >= dp->inblocks - nblks, file: fs/xfs/libxfs/xfsdabtree.c, line: 2387 WARNING: fs/xfs/xfsmessage.c:104 at assfail+0x46/0x4a [xfs], CPU#0: xfsscrub/1426511 CPU: 0 UID: 0 PID: 1426511 Comm: xfsscrub Tainted: G W 7.3.0-rc2-djwx #rc2 PREEMPT(lazy) 6e418570b606a39783b0e7e7b30dc407b965f9e8 Tainted: [W]=WARN RIP: 0010:assfail+0x46/0x4a [xfs] RSP: 0018:ffffc900010d7890 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00000000ffffffd1 RDX: 0000000000000000 RSI: 0000000000000021 RDI: ffffffffa059fd38 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000000a R11: 000000007fffffff R12: ffffc900010d7940 R13: ffff888368d8f980 R14: ffffc900010d7a48 R15: ffffc900010d78d0 FS: 00007f445c5ce680(0000) GS:ffff8884a97ea000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f443803b9a8 CR3: 0000000107a4b000 CR4: 00000000003506f0 Call Trace: <TASK> xfsdagrowinodeint+0x2e0/0x300 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xfsdir2growinode+0x6e/0x150 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xfsdir2sftoblock+0x149/0x870 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xrepdirswapprep+0xe2/0x110 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xrepdirswap+0xfb/0x2f0 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xrepdirrebuildtree+0x99/0x100 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xrepdirectory+0x83/0x1c0 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xrepattempt+0x4f/0x1e0 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xfsscrubmetadata+0x393/0x5b0 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xfsiocscrubvmetadata+0x306/0x570 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] xfsfileioctl+0xa4f/0x1150 [xfs 5de2257e14108c136f11317e6bbb8ac77efd392c] x64sysioctl+0x76/0xc0 dosyscall64+0x7a/0x3b0 entrySYSCALL64afterhwframe+0x4b/0x53
This is a consequence of commit 0fe77e57588b98, which added the following assertion to xfsdagrowinodeint:
ASSERT(args->total >= dp->inblocks - nblks);
Tracing this back to xrepdirswapprep, I noticed that the xfsdaargs object that's passed to xfsdir2sftoblock sets args->total to 1. This is incorrect because mkfs set the directory block size to 8k and the filesystem block size to 4k. In other words, args->total should be 2 here, not 1.
Dave Chinner tripped over the same problem with the same branch through a different channel -- his test setup set the fs block size to 1k, in which case the directory block size is still set to 4k. Here, args->total should be 4.
Changing the assignment of args->total to sc->mp->mdirgeo->fsbcount makes the assertion go away, but that isn't a complete fix. In xreptempexchestimate, we also incorrectly assume that a shortform conversion requires 1 fsblock when it should be mdirgeo->fsbcount. Without that, we can under-reserve space in the transaction and cause a filesystem shutdown.
Note that the xfsdabufnfsb helper will compute the correct value for directories and xattr, so we use that instead of open-coding the logic. Also fix xrepxattrswapprep to assign args->total via xfsdabufnfsb to avoid one logic bomb if we ever support multi-fsblock attrs.
Tripped-by: 0fe77e57588b98 ("xfs: assert the reservation covers each da fork growth")
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.116-1Fixed in 7.2.15-1Fixed in 7.3.4-1 - Upgrade
Upgrade
debian/linux-6.12to a version that resolves this vulnerability.Fixed in 6.12.115-2~deb12u1 - Upgrade
Upgrade
ubuntu/linux-aws-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1017.18~24.04.1 - Upgrade
Upgrade
ubuntu/linux-azure-fde-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1019.19~24.04.1 - Upgrade
Upgrade
ubuntu/linux-gcp-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1017.19~24.04.1 - Upgrade
Upgrade
ubuntu/linux-hwe-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-42.42~24.04.1 - Upgrade
Upgrade
ubuntu/linux-oracle-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1016.18~24.04.1 - Upgrade
Upgrade
ubuntu/linux-riscv-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-42.42.1~24.04.1 - Upgrade
Upgrade
ubuntu/linuxto a version that resolves this vulnerability.Fixed in 7.0.0-42.42 - Upgrade
Upgrade
ubuntu/linux-awsto a version that resolves this vulnerability.Fixed in 7.0.0-1016.17 - Upgrade
Upgrade
ubuntu/linux-azureto a version that resolves this vulnerability.Fixed in 7.0.0-1020.21 - Upgrade
Upgrade
ubuntu/linux-azure-fdeto a version that resolves this vulnerability.Fixed in 7.0.0-1019.19 - Upgrade
Upgrade
ubuntu/linux-gcpto a version that resolves this vulnerability.Fixed in 7.0.0-1016.18 - Upgrade
Upgrade
ubuntu/linux-gketo a version that resolves this vulnerability.Fixed in 7.0.0-1010.11 - Upgrade
Upgrade
ubuntu/linux-ibmto a version that resolves this vulnerability.Fixed in 7.0.0-1017.17 - Upgrade
Upgrade
ubuntu/linux-oem-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1017.17 - Upgrade
Upgrade
ubuntu/linux-oracleto a version that resolves this vulnerability.Fixed in 7.0.0-1015.16 - Upgrade
Upgrade
ubuntu/linux-raspito a version that resolves this vulnerability.Fixed in 7.0.0-1023.23 - Upgrade
Upgrade
ubuntu/linux-realtimeto a version that resolves this vulnerability.Fixed in 7.0.0-43.43.1 - Upgrade
Upgrade
ubuntu/linux-riscvto a version that resolves this vulnerability.Fixed in 7.0.0-42.42.1 - Compensating control
In xrep_dir_swap_prep, replace the hard-coded args->total assignment of 1 with a value computed by xfs_dabuf_nfsb, so directory shortform conversion reserves the required number of filesystem blocks.
- Compensating control
In xrep_xattr_swap_prep, assign args->total using xfs_dabuf_nfsb rather than assuming 1 fsblock, avoiding under-reservation for multi-fsblock attributes.
- Compensating control
In xrep_tempexch_estimate, account for shortform conversion using sc->mp->m_dir_geo->fsbcount instead of assuming it requires 1 fsblock.
Event History
Frequently Asked Questions
What filesystem configuration was associated with the observed failure?
The assertion was observed during XFS QA using MKFS_OPTIONS="-n size=8192" on an XFS for-next build identified as 7.3-rc2.
How was the issue detected in testing?
It was triggered while xfs_scrub was running as UID 0. The kernel reported an XFS assertion failure in fs/xfs/libxfs/xfs_da_btree.c and emitted a warning.
Is a fix available?
The issue is described as resolved, and two stable kernel Git commits are provided as references: b950e84acd072ac648ace4fea53c0b1212da4b2c and 4d3c07591534517c633945c8d8e6526f10e3fabc.