CVE-2026-100092: f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to use bioinatomic() in f2fsreadendio()
f2fsreadendio() uses "intask() && !irqsdisabled()" to decide whether it is safe to sleep, the result is passed down as @intask to: - f2fsputdic() -> f2fsfreedic() -> f2fsreleasedecompmem() -> vmunmapram(), which may sleep. - f2fsendreadcompressedpage() -> f2fscachecompressedpage() -> f2fsgrabcache() -> f2fslockcache(), which may sleep in waitonbitlock().
However, the check still treats below task contexts as sleepable: - with spinlock held via spinlock(), i.e. preempt count != 0 while irqs are enabled. - with BH disabled via localbhdisable(). - inside an RCU read lock on kernels with CONFIGPREEMPTION. - with any spinlock held on kernels without CONFIGPREEMPTCOUNT.
So the "sleeping function called from invalid context" issue fixed by commit 08a7efc5b02a ("f2fs: vmunmapram() may be called from an invalid context") can still be triggered.
The block layer provides bioinatomic() for exactly this purpose, it checks rcupreemptdepth() and preemptible(), and conservatively returns true if CONFIGPREEMPTCOUNT is disabled, let's use it instead. The difference is as below:
old: intask = intask() && !irqsdisabled() new: intask = !bioinatomic()
Context | old intask | new intask -------------------------------------+----------------+---------------- Hard IRQ / softirq | false | false IRQs disabled | false | false spinlock() held, IRQs enabled | true (wrong) | false BH disabled by localbhdisable() | true (wrong) | false RCU read lock (CONFIGPREEMPTION) | true (wrong) | false Spinlock held, w/o PREEMPTCOUNT | true (wrong) | false
Note that on kernels without CONFIGPREEMPTCOUNT, bioinatomic() always returns true, so dic freeing will always be offloaded to sbi->wq, and compressed pages will not be cached in f2fsreadendio(); this is the price of correctness, since there is no way to tell whether the current context can sleep.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In f2fs_read_end_io(), use bio_in_atomic() instead of in_task() && !irqs_disabled() to determine whether the current context can sleep.
Event History
Frequently Asked Questions
Which execution contexts can trigger the invalid-sleep condition?
The affected read completion path can incorrectly treat execution as sleepable while a spinlock is held, bottom halves are disabled, or an RCU read lock is held on kernels with CONFIG_PREEMPTION. These contexts can reach operations that may sleep, including vm_unmap_ram() and wait_on_bit_lock().
Are kernels without CONFIG_PREEMPT_COUNT relevant?
Yes. On kernels without CONFIG_PREEMPT_COUNT, the existing check can also misclassify contexts with any spinlock held as sleepable. The replacement bio_in_atomic() check conservatively treats such configurations as atomic.