CVE-2026-139796: ocfs2/heartbeat: serialize concurrent writes to a region's dev attribute
In the Linux kernel, the following vulnerability has been resolved:
ocfs2/heartbeat: serialize concurrent writes to a region's dev attribute
o2hbregiondevstore() checks reg->hrbdevfile to see if the region is already started, but nothing stops two writers from doing that at the same time. configfs only serializes writes through the same open file, so two processes that each open the dev attribute can both get past the check:
A: hrbdevfile is NULL, opens file A, sets hrbdevfile = A B: hrbdevfile is NULL, opens file B, sets hrbdevfile = B A: start fails, fput(hrbdevfile) drops B, sets it to NULL B: start fails, fput(NULL)
Both calls also use the same hrslots, hrslotdata and hrtmpblock, so the error paths can free the slot data twice.
syzbot hit the fput(NULL) with an unbound loop device, where every start fails with -EIO. With four threads doing the same thing on a KASAN kernel I get both crashes within a second:
BUG: KASAN: double-free in o2hbunmapslotdata+0x14d/0x2f0 BUG: kernel NULL pointer dereference, address: 0000000000000158
Add a mutex to the region and hold it in devstore(), in the blockbytes, startblock and blocks stores, and in devshow(), since they all look at hrbdevfile. devstore() cleans up with goto, so it takes the mutex in a small wrapper rather than with guard(). The mutex is dropped while devstore() waits for the heartbeat to become steady, which takes seconds, so a read of dev doesn't stall behind a start. hrbdevfile is already set at that point, so other writers still get -EINVAL, and the cleanup after the wait retakes the mutex.
With the patch the same test ran for 10 minutes with lockdep on and nothing was reported. So did a second one, with a working loop device, that interrupts starts during the wait while other threads read and write the attributes.
Affected Software
Event History
Frequently Asked Questions
What access is needed to trigger this issue?
An attacker or local process needs to be able to perform concurrent writes to an OCFS2 heartbeat region's configfs dev attribute through separate open file handles. The race occurs because configfs serializes writes only through the same open file.
What conditions make exploitation more likely?
The issue requires two or more writers to pass the check for an unstarted region at the same time. Failed region starts can expose the faulty cleanup paths; the reported reproducer used an unbound loop device that caused starts to fail with -EIO.
What can happen if the race is triggered?
Concurrent operations can overwrite the region's block-device file state and use shared slot-related data simultaneously. Reported outcomes include a double-free and a kernel NULL pointer dereference, which can crash the kernel.
How is the issue resolved?
The fix adds a mutex for each heartbeat region and uses it to serialize dev attribute handling, related block and slot configuration stores, and dev attribute reads. The listed stable-kernel references identify commits containing the fix.