ARM-software / abi-aa

Application Binary Interface for the Arm® Architecture
Other
878 stars 173 forks source link

RFC: Add pagesize to __ifunc_arg_t #265

Open fmayer opened 1 month ago

fmayer commented 1 month ago

Hey!

I am working on HWASan where we have some initialization logic in ifunc resolvers. For non-4K page size systems, it would be nice to know the page size (because we call mmap via our own implementation of syscall). __ifunc_arg_t solves this for HWCAP (and HWCAP2), so it seems natural to also add the page size. I would be happy to do the change in glibc and Android Bionic.

What do you think?

smithp35 commented 1 month ago

Thanks for creating the issue.

I expect the place to document this would be in https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#941gnu-c-library-ifunc-interface

I think @nsz-arm would likely be the best person to discuss this and the implementation choices. Although it may be best to do that on the glibc/bionic mailing lists as I see this as a GNU/Linux platform decision that I'd certainly be happy to document the outcome if __ifunc_arg_t changed.

Some thoughts, I'm mostly a linker person so I've not got too much expertise in this area:

fmayer commented 1 month ago

Another idea would be to put a pointer to the auxval array there, that would let people extract pagesize but also other information they might need.

nsz-arm commented 4 weeks ago

we will have to extend ifunc arg with hwcap3 soon so it is a good time to discuss extensions.

i think pagesize is ok to add, pointer to auxv may be.

for the record, the constraints are that an ifunc resolver

if auxv is user modifiable (according to interface contracts, not according to page protection) then a libc would need to make a copy to pass it to ifunc resolvers (unbounded memory) even then it would be fine to pass an unspecified subset to resolvers in auxv format, however it is ugly to parse auxv in a resolver when all you need is hwcap flags. (i think argv and env are owned by the user application, but auxv is owned by the libc, so probably fine to pass.)

it's hard to find out the pagesize so that's a valid request (i believe one could do it with a raw mprotect syscall, with some handwaving, but i would not recommend using raw syscalls).