CVE-2026-31703: writeback: Fix use after free in inode_switch_wbs_work_fn()
In the Linux kernel, the following vulnerability has been resolved:
writeback: Fix use after free in inodeswitchwbsworkfn()
inodeswitchwbsworkfn() has a loop like:
wbget(newwb); while (1) { list = llistdelall(&newwb->switchwbsctxs); / Nothing to do? / if (!list) break; ... process the items ... }
Now adding of items to the list looks like:
wbqueueisw() if (llistadd(&isw->list, &wb->switchwbsctxs)) queuework(iswwq, &wb->switchwork);
Because inodeswitchwbsworkfn() loops when processing isw items, it can happen that wb->switchwork is pending while wb->switchwbsctxs is empty. This is a problem because in that case wb can get freed (no isw items -> no wb reference) while the work is still pending causing use-after-free issues.
We cannot just fix this by cancelling work when freeing wb because that could still trigger problematic 0 -> 1 transitions on wb refcount due to wbget() in inodeswitchwbsworkfn(). It could be all handled with more careful code but that seems unnecessarily complex so let's avoid that until it is proven that the looping actually brings practical benefit. Just remove the loop from inodeswitchwbsworkfn() instead. That way when wbqueueisw() queues work, we are guaranteed we have added the first item to wb->switchwbsctxs and nobody is going to remove it (and drop the wb reference it holds) until the queued work runs.
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2026-31703?
The severity of CVE-2026-31703 is classified as high due to its impact on memory safety in the Linux kernel.
How do I fix CVE-2026-31703?
To fix CVE-2026-31703, update your Linux kernel to the latest version that includes the patch for this vulnerability.
What systems are affected by CVE-2026-31703?
CVE-2026-31703 affects specific versions of the Linux kernel, particularly those with the writeback subsystem.
What type of vulnerability is CVE-2026-31703?
CVE-2026-31703 is a use-after-free vulnerability, which can lead to memory corruption and potential system compromise.
Is CVE-2026-31703 actively exploited?
As of now, there are no public reports indicating that CVE-2026-31703 is actively being exploited in the wild.