Closed Bug 1470701 Opened 6 years ago Closed 6 years ago

Possible crash in elfhack bootstrap code when run-time page size doesn't match alignment of executable PT_LOADs

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file)

No description provided.
Comment on attachment 8987304 [details] Bug 1470701 - Use run-time page size when changing mapping permissions in elfhack injected code. https://reviewboard.mozilla.org/r/252546/#review259314 ::: build/unix/elfhack/inject.c:67 (Diff revision 1) > static inline __attribute__((always_inline)) > -void relro_pre() > +void do_relocations_with_relro(void) > { > + long page_size = sysconf_cb(_SC_PAGESIZE); > + uintptr_t aligned_relro_start = ((uintptr_t) relro_start) & ~(page_size - 1); > + uintptr_t aligned_relro_end = ((uintptr_t) relro_end) & ~(page_size - 1); Am I missing something, or should this be rounding up and not down?
(In reply to Jed Davis [:jld] (⏰UTC-6) from comment #2) > Comment on attachment 8987304 [details] > Bug 1470701 - Use run-time page size when changing mapping permissions in > elfhack injected code. > > https://reviewboard.mozilla.org/r/252546/#review259314 > > ::: build/unix/elfhack/inject.c:67 > (Diff revision 1) > > static inline __attribute__((always_inline)) > > -void relro_pre() > > +void do_relocations_with_relro(void) > > { > > + long page_size = sysconf_cb(_SC_PAGESIZE); > > + uintptr_t aligned_relro_start = ((uintptr_t) relro_start) & ~(page_size - 1); > > + uintptr_t aligned_relro_end = ((uintptr_t) relro_end) & ~(page_size - 1); > > Am I missing something, or should this be rounding up and not down? No, the rounding is down because if the end of the segment is not page aligned, that last page can't be made read-only, since it will contain bits that are read-write.
Comment on attachment 8987304 [details] Bug 1470701 - Use run-time page size when changing mapping permissions in elfhack injected code. https://reviewboard.mozilla.org/r/252546/#review259726 ::: build/unix/elfhack/inject.c:65 (Diff revision 1) > + long page_size = sysconf_cb(_SC_PAGESIZE); > + uintptr_t aligned_relro_start = ((uintptr_t) relro_start) & ~(page_size - 1); > + uintptr_t aligned_relro_end = ((uintptr_t) relro_end) & ~(page_size - 1); jld's concern about `aligned_relro_end` probably merits a comment about what is going on here.
Attachment #8987304 - Flags: review?(nfroyd) → review+
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/ded856841553 Use run-time page size when changing mapping permissions in elfhack injected code. r=froydnj
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Depends on: 1505608
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: