CVE-2026-99757: btrfs: sysfs: restore NOFS context on early return in btrfs_sysfs_add_block_group_type()
In the Linux kernel, the following vulnerability has been resolved:
btrfs: sysfs: restore NOFS context on early return in btrfssysfsaddblockgrouptype()
btrfssysfsaddblockgrouptype() sets up a NOFS context with memallocnofssave() because kobjectadd() performs GFPKERNEL allocations deep in its call chain, and the function may be called while holding a transaction handle or a lock required for a transaction commit, where reclaim could deadlock.
Every other return path of this function calls memallocnofsrestore() except the early return taken when another thread has already created the kobject for the same raid index (this can happen when restriping). Taking that path leaves PFMEMALLOCNOFS set on the calling task, so all subsequent memory allocations performed by that task remain restricted to the NOFS scope, which may lead to unexpected allocation failures or deadlocks later on.
Restore the NOFS context before returning from that path.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Compensating control
In btrfs_sysfs_add_block_group_type(), restore the NOFS context with memalloc_nofs_restore() before the early return when another thread has already created the kobject for the same RAID index.
Frequently Asked Questions
Under what conditions can this issue occur?
The affected path is reached when btrfs_sysfs_add_block_group_type() finds that another thread has already created the kobject for the same RAID index. The description notes that this can occur during restriping.
What is the operational impact if the early-return path is taken?
The calling task retains the PF_MEMALLOC_NOFS state after returning. Its later memory allocations remain restricted to the NOFS scope, which can cause unexpected allocation failures or later deadlocks.
Why does this function use a NOFS memory-allocation context?
It uses NOFS because kobject_add() can perform GFP_KERNEL allocations, while the function may run with a transaction handle or a lock needed for transaction commit held. Reclaim in that context could deadlock.