5eea203ec8
mitigation against similar bugs. The operations on segment registers can generate a page fault if there is an issue when touching the in-memory gdt. Theoretically, it is never supposed to happen, since the gdt is mapped correctly. However, in the kernel we allow the gdt to be resized, and to do that, we allocate the maximum amount of va needed by it, but only kenter a few pages until we need more. Moreover, to avoid reloading the gdt each time we grow it, the 'size' field of gdtr is set to the maximum value. All of this means that if a mov or iretq is done with a segment register whose index hits a page that has not been kentered, a page fault is sent. Such a page fault, if received in kernel mode, does not trigger a swapgs on amd64; in other words, the kernel would be re-entered with the userland tls. And there just happens to be a place in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. The mitigation simply consists in abandoning the gdt_grow mechanism and allocating/kentering the maximum size right away, in such a way that no page fault can be triggered because of segment registers. |
||
---|---|---|
.. | ||
aoutm68k | ||
common | ||
freebsd | ||
ibcs2 | ||
linux | ||
linux32 | ||
m68k4k | ||
ndis | ||
net | ||
netbsd32 | ||
netinet6 | ||
osf1 | ||
ossaudio | ||
sunos | ||
sunos32 | ||
svr4 | ||
svr4_32 | ||
sys | ||
ultrix | ||
vax1k | ||
Makefile | ||
Makefile.syscall |