CVE-2026-99036: dm: fix reading free memory in do_resume
In the Linux kernel, the following vulnerability has been resolved:
dm: fix reading free memory in doresume
When doresume calls dmtablegetmode(newmap), the call is done without holding any locks (it only holds a reference to the md). It may be possible that another concurrent ioctl on the same device will swap table after dmswaptable and before dmtablegetmode. In this case, dmtablegetmode(newmap) reads freed memory.
This race condition was triggered by syzbot.
This commit fixes the race by reading mode of the new table before dmswaptable. Note that newmap is also passed to dmimaneedmeasure, but this function doesn't attempt to dereference it, so this call should be safe.
Note that this is not a security bug because only root can trigger it and the commonly used tools such as lvm or cryptsetup do not call the ioctls concurrently, so that they can't trigger it acceidentally.