Bug 588818 - core file module detection confused by core from a PIE
Summary: core file module detection confused by core from a PIE
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: elfutils
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Roland McGrath
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 579038
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-04 16:51 UTC by Denys Vlasenko
Modified: 2010-07-06 17:19 UTC (History)
14 users (show)

Fixed In Version: elfutils-0.148-1.fc12
Clone Of: 579038
Environment:
Last Closed: 2010-07-01 18:52:51 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Comment 1 Roland McGrath 2010-05-04 21:11:15 UTC
Reproduced with:

$ gcc -o piedie -fpie -pie -xc <(echo 'main(){abort();}')
$ ./piedie
Aborted (core dumped)
$ eu-unstrip -n --core=core.28229 
eu-unstrip: No modules recognized in core file

Comment 5 Petr Machata 2010-05-05 16:22:54 UTC
In dwfl_link_map_report it looks at the ELF of the main (pie) binary, and reads dyn_vaddr.  That's value like 0x2009f8, which is outside all reported segments.  I think the problem is that we don't account for bias as we do when reporting segments.

Comment 6 Petr Machata 2010-05-05 16:28:30 UTC
The "value like" bit was meant to mean "small value", as opposed to values like 0x7f6a0d996000 for addresses where the libraries are mapped".

Comment 7 Petr Machata 2010-05-05 18:40:18 UTC
(In reply to comment #5)
>  I think the problem is that we don't account for bias

... which I don't know how to obtain.  I thought AT_BASE would hold the bias for the main binary, but that doesn't seem to be it.  There is a number with roughly the right magnitude, but it's still too small for bias (in my test case it's 0x7f35fe376000, the binary was mapped to 0x7f6a0d996000).

We know the address of PHDR block, but not of EHDR (then we could do AT_ENTRY - e_entry).  I'm not sure if we can assume anything about the size of EHDR, the presence of e_phoff implies that more fields could be added to the end of EHDR, there could be padding, or whatnot.  Hmm, what about looking sizeof (EHDR) bytes back, checking if the magic holds, and if not, scanning back for magic "reasonably far"?

Comment 8 Roland McGrath 2010-05-05 19:45:08 UTC
Fixed upstream.

Comment 9 Fedora Update System 2010-06-29 04:52:23 UTC
elfutils-0.148-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/elfutils-0.148-1.fc12

Comment 10 Fedora Update System 2010-06-29 04:52:29 UTC
elfutils-0.148-1.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/elfutils-0.148-1.fc13

Comment 11 Fedora Update System 2010-06-29 15:32:08 UTC
elfutils-0.148-1.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update elfutils'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/elfutils-0.148-1.fc13

Comment 12 Fedora Update System 2010-06-29 15:34:25 UTC
elfutils-0.148-1.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update elfutils'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/elfutils-0.148-1.fc12

Comment 13 James Laska 2010-06-30 14:20:43 UTC
Using the reproducer in comment#1, the reported problem does not occur with elfutils-0.148-1.fc13.

$ gcc -o piedie -fpie -pie -xc <(echo 'main(){abort();}')
/proc/self/fd/63: In function ‘main’:
/proc/self/fd/63:1: warning: incompatible implicit declaration of built-in function ‘abort’
$ ./piedie 
$ ulimit -c unlimited
$ eu-unstrip -n --core core.9471 
0x7f27472a1000+0x201000 586b9b81baedc58dcdd34f630856e401f0f08032@0x7f27472a124c - - [pie]
0x7fff509ff000+0x1000 9eef3c8dabad1ba6746e5fef74878ba17e416e38@0x7fff509ff2f8 . - linux-vdso.so.1
0x7f2746d01000+0x37f000 f855edf9e7f0567206e280428d6d405f30a5b3f9@0x7f2746d01280 /lib64/libc.so.6 - libc.so.6
0x7f2747080000+0x221000 f9554ea901052eaee919938a843d292b129532db@0x7f27470801d8 /lib64/ld-linux-x86-64.so.2 - ld-linux-x86-64.so.2

Comment 14 Fedora Update System 2010-07-01 18:52:42 UTC
elfutils-0.148-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2010-07-06 17:19:15 UTC
elfutils-0.148-1.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.