Bug 112592
Summary: | prelinking causes mmap() to SEGV in some cases | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Kars de Jong <jongk> | ||||
Component: | prelink | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | |||||
Severity: | medium | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 1 | ||||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | i386 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2003-12-24 00:14:18 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Kars de Jong
2003-12-23 21:36:51 UTC
Created attachment 96684 [details]
Example test program
Hmm, it looks like I spoke too soon... It still crashes sometimes, even with prelinking disabled. After some more investigation, it looks like the Exec-shield functionality has something to do with it too. On my system with Exec-shield enabled and prelink disabled, it still crashes. I understand why too now, because the fixed memory mapping of 4 MB at address 0 my program makes sometimes overlaps with the place where the C library is mapped. Using setarch fixes this issue, and also disabling Exec-shield globally. However, this doesn't work for a prelinked library. I guess I just can't use prelinking in this case, unless I can somehow make it exclude certain memory ranges... (I *need* the memory mapping at address 0 since this is some kind of emulator). Exec-shield places libraries below the binary (starting from 1MB+4KB up to the beginning of the binary). If your program needs to use MAP_FIXED on a region not given by the kernel to you (e.g. MAP_FIXED on previously returned address from mmap without MAP_FIXED if the region is smaller or equal is always ok), then you need to tell the system about it. The best way is to create a p_flags 0 PT_LOAD segment with p_filesz 0 and p_memsz equal to the size of the region you want to reserve, p_vaddr equal to the start address. Then it will work even with exec-shield, prelinking etc. ATM it is not exactly trivial to create such PT_LOAD segments, it needs quite many changes to the linker script (see PHDRS linker script command), but it is on my TODO list to simplify this. Alternatively, you need to disable exec-shield for that particular program. With rawhide glibc and maybe already rawhide kernel (am not sure whether the patch is in there already) if you build your program as PIE and disable exec-shield for it, it should load even prelinked libraries high. Or, if you don't want exec-shield system-wide, you can add --no-exec-shield option to /etc/sysconfig/prelink and force reprelinking. |