[PATCH] D64906: [ELF][PPC] Allow PT_LOAD to have overlapping p_offset ranges

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 03:40:45 PDT 2019


peter.smith added a comment.



> I would like to do a bit more research about RELRO, as I can't see from this patch alone. I think it is fine if RELRO is double mapped into an RO page. However if RELRO is adjacent to RW segments I think it could be a bad idea to have something like
> 
> | VA [0x10000, 0x10020) | .data.rel.ro | PA [0x10000, 0x10020) |
> | VA [0x20020, ...)     | .data        | PA [0x10020, ...)     |
> |
> 
> As in theory (I'm not sure about how this works in the OS/loader so I could have this wrong) if the physical contents of .data was mapped RW from 0x10000 -> 0x20000 we'd have an ability to write to the .data.rel.ro via .data.
> 
> Is there some other part of the code that prevents this or does some other mechanism in the loader/OS prevent this from happening?

To answer my own question https://sourceware.org/binutils/docs-2.32/ld/Builtin-Functions.html has DATA_SEGMENT_RELRO_END which mentions:

  DATA_SEGMENT_ALIGN is padded so that exp + offset is aligned to the commonpagesize argument given to DATA_SEGMENT_ALIGN

There is also the comment in DATA_SEGMENT_ALIGN

  commonpagesize should be less or equal to maxpagesize and should be the system page size the object wants to be optimized for while still running on system page sizes up to maxpagesize. Note however that ‘-z relro’ protection will not be effective if the system page size is larger than commonpagesize. 

So this implies that if you are on a linux distro with a 64k page size and you want full relro protection you must increase the common page size to match the max page size.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64906/new/

https://reviews.llvm.org/D64906





More information about the llvm-commits mailing list