2 ms·
It ought to work in a freestanding environment. If it doesn’t, then it’s IMO a gcc bug. I found a GCC bug which may or may not be the ipxe issue. Are you seein
by amluto 6y ago
It ought to work in a freestanding environment. If it doesn’t, then it’s IMO a gcc bug. I found a GCC bug which may or may not be the ipxe issue. Are you seeing another failure in a freestanding environment? If so, I don’t suppose you either have a reproducer or can point at a problem in the generated code?
- mlyle 6y agoI don't know any specifics. It was my understanding, though, that you needed to be careful mixing CET-aware code and non-CET aware code. Is this wrong? Can you call into the BIOS, EFI drivers, and have interrupt handlers and not worry about any of this at all? It really should be OK freestanding without any additional CET-specific initialization code support and mixed with non-CET code? If so, I stand corrected. (But then, what's all this machinery for marking code that doesn't use endbranch in glibc, ld.so, the kernel, etc, and the legacy code page bitmap for?)
- amluto 6y agoI would say that the issue isn't really mixing CET-aware and non-CET-aware code. The issue is using non-CET-aware code with CET enabled. If you have code that plays games with mismatched CALL and RET or with rewriting the stack (which includes retpolines and possibly 32-bit PIC code), then SHSTK will make it crash. And if you have code that takes pointers to non-IBT functions, then you will crash unless you set up the legacy bitmap. But all of this is moot unless something turns CET on. The actual semantics of when the combination of gcc, ld, and glibc will try to turn CET on are not documented, as far as I can tell. And, to be fair, as my bug report shows, there can also be issues if something has a different ABI when compiled with and without CET enabled. This shouldn't happen, but apparently it did.
- mlyle 6y ago> The actual semantics of when the combination of gcc, ld, and glibc will try to turn CET on are not documented, as far as I can tell. Yes. And a complicating thing is here there's no loader or normal initialization code, because PXE is freestanding and invoked directly by the BIOS/EFI. CET is -probably- off... And yes, are there any dependencies between the init code changes and GCC enabling CET and GCC builtins?
- amluto 6y agoAny CET init code ought to be confined to glibc and/or the kernel or whatever code is untimely loading your program. I hope glibc isn’t involved in iPXE :). CET had better be off for UEFI programs when they’re loaded unless that program has a special header, based on spec that I doubt exists, telling the loader to enable CET.