tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Statically allocated guard pages in ELF
> Date: Fri, 28 Mar 2025 19:30:55 +0000
> From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
>
> Setting aside the copied & pasted mmap/mprotect logic across three
> files, I'm not entirely happy with the patch because it adds several
> mmap/mprotect calls to every program startup in libc.
>
> Can it be done with an ELF trick to request a guard page instead, so
> there's no additional syscall overhead but the kernel sets up a
> PROT_NONE page before each table it already maps from the file?
On reflection, I realize this is a fool's errand because the LOAD
commands _in a shared library_ like libc.so are executed by rtld by
calling mmap/mprotect, so nothing can be saved by this ELF magic.
(For a static executable -- or the rtld interpreter itself -- the
kernel will execute the LOAD commands, possibly with lower overhead
than mmap/mprotect syscalls, but that's the only case that this could
improve.)
Home |
Main Index |
Thread Index |
Old Index