Re:Writing an OS in Rust: Catching CPU Exceptions
by bogomipz on Sunday May 29, 2016 @10:33AM
(#11796485)
I looked it up - segmentation in long mode. I'm curious how both Linux and BSD had/have gotten it "wrong" for so long? That just sounds unusual and likely not an oversight. Can you elaborate?
[ Parent
| on HN ]
Re:Writing an OS in Rust: Catching CPU Exceptions
by amluto on Tuesday May 31, 2016 @07:40PM
(#11811139)
It's not segmentation. It's effectively just one extra register usable only for address offsets.
Unfortunately, on x86, privilege transitions and exception handling is an incoherent mess, and, worse, privilege changes (via IRET) can fail. Most kernels messed up what happens when IRET fails for obscure reasons, resulting in corrupting the value of GSBASE and therefore allowing a malicious program to change the targets of certain kernel memory accesses.
The result was "BadIRET", which I discovered, fixed on Linux, and reported via CERT (not a good experience) to other vendors. Someone else named it, and a few other people wrote exploits based on it.