Encoding page size in the ELF header
Frank Ch. Eigler
fche@redhat.com
Sun Sep 27 17:24:00 GMT 2015
Hi -
> > >>> Could the app more portably use
> > >>> int critical_data __attribute__((section(".data.critical")));
> > >>> and maybe a linker script widgetry to assure padding [...]
> [...]
> To see why, suppose I have the following PT_LOAD segments:
>
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x000000 0x00000000 0x00000000 0x84cc4 0x84cc4 R E 0x1000
> LOAD 0x085000 0x00085000 0x00085000 0x00458 0x0240c RW 0x1000
> [...] But the largest power of 2 to which 0x85000 is
> aligned is 0x1000 (4k); 0x85000 mod 0x2000 is 0x1000. Thus it's
> impossible for both load segments to be simultaneously aligned mod
> 0x2000 or any larger power of two.
An application that wishes to protect itself against larger page
sizes, but still play page-protection tricks, can include pessimistic
padding (ahead and/or behind) for its mprotecty sections, basically
hard-coding a maximum acceptable page size. If the data protection
with current tooling is that important, they can probably afford even
a 1MB page full of padding/alignment.
- FChE
More information about the Libc-alpha
mailing list