Page MenuHomeFreeBSD

loader: Allocate trampoline as EfiLoaderCode, not Data
ClosedPublic

Authored by emaste on Tue, Jul 21, 7:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Aug 11, 11:45 AM
Unknown Object (File)
Sun, Aug 9, 3:19 AM
Unknown Object (File)
Sat, Aug 8, 11:06 PM
Unknown Object (File)
Sat, Aug 8, 4:30 PM
Unknown Object (File)
Sat, Aug 8, 11:03 AM
Unknown Object (File)
Sat, Aug 8, 8:33 AM
Unknown Object (File)
Fri, Aug 7, 11:24 PM
Unknown Object (File)
Fri, Aug 7, 6:11 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I tested this patch on the nigeria-sp7 in the Kitchener office, and it resolves an exception that originally took place during the loader stage.

stand/efi/loader/arch/amd64/elf64_freebsd.c
114

The trampoline stack is located at the same page as code. So for EfiLoaderCode, could it be that some fw would deny the write?

stand/efi/loader/arch/amd64/elf64_freebsd.c
114

I am not certain, but believe that we will get only RWX or RW from AllocatePages for code or data. It may happen for PE image sections but not for allocations, I think.

If this is a concern we'd need to split into two allocations I suppose. Or EFI_MEMORY_ATTRIBUTE_PROTOCOL

This revision is now accepted and ready to land.Tue, Jul 21, 9:01 PM

So you can't allocate pages for code read only... you've got to write to them sometime and there's no interface to change the mapping.

EFI_MEMORY_ATTRIBUTE_PROTOCOL is the interface to change mapping

EFI_MEMORY_ATTRIBUTE_PROTOCOL is the interface to change mapping

Oh! That's shiny. I'll have to try that out... While sharing the stack and trampoline code is super-old-school, I know that some uses of that cause security problems... So far none here, but we'll keep this in mind if something pops up or I get a bunch of time to test it, etc, which I might have later in the year.