Bug 512840 - [PATCH] Assert fail in libelf when file contains a gap between sections
Summary: [PATCH] Assert fail in libelf when file contains a gap between sections
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:
Blocks: 516995
TreeView+ depends on / blocked
 
Reported: 2009-07-20 22:26 UTC by Lubomir Rintel
Modified: 2009-08-20 20:59 UTC (History)
3 users (show)

Fixed In Version: 0.142-1.fc10
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-08-20 20:53:55 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Fix an assert fail with gaps between sections (1.23 KB, text/plain)
2009-07-20 22:26 UTC, Lubomir Rintel
no flags Details
Offending file (i386 ELF32, passes elflint) (1.80 KB, application/binary)
2009-07-20 22:35 UTC, Lubomir Rintel
no flags Details

Description Lubomir Rintel 2009-07-20 22:26:23 UTC
Created attachment 354399 [details]
Fix an assert fail with gaps between sections

Description of problem:

When updating grub2 package, I hit an assertion fail when running find-debuginfo.sh. Further investigation led me to a rather minimal test case and a patch which somehow fixes the problem and passes the test suite, though may not be completely correct due to my lack of expertise.

Version-Release number of selected component (if applicable):

elfutils-0.141-1.fc12.i586

How reproducible:

Always, will attach reproducer.

Actual results:

crasher: elf32_updatefile.c:383: __elf32_updatemmap: Assertion `scn_start + dl->data.d.d_off + dl->data.d.d_size == last_position' failed.
make: *** [run] Aborted (core dumped)

Comment 1 Lubomir Rintel 2009-07-20 22:35:18 UTC
Created attachment 354401 [details]
Offending file (i386 ELF32, passes elflint)

Reproducer (hope it's short enough so that posting inline's not a problem):

#include <stdlib.h>
#include <fcntl.h>
#include <libelf.h>

main ()
{
        elf_version (EV_CURRENT);
        Elf *elf = elf_begin (open ("setjmp.elf", O_RDWR),
                ELF_C_RDWR_MMAP, NULL);
        elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);

        /* Section 8 will become section 13 when sorted.
         * elf_getdata causes scn->data_list_rear be not-NULL */
        elf_getdata (elf_getscn (elf, 8), NULL);

        elf_update (elf, ELF_C_WRITE);
        return 0;
}

Sections in setjmp.elf:

Sorted  Orig   Section           Start  Size
Index   Index  Name
0       00                       000000 000000
1       01     .text             000034 000030
2       02     .data             000064 000000
3       03     .bss              000064 000000
4       04     .modname          000064 000007
5       05     .note.GNU-stack   00006b 000000
6       06     .comment          00006b 00002e
7       07     .debug_info       000099 00006f
8       09     .debug_abbrev     000108 000033
9       10     .debug_line       00013b 00001d
10      11     .debug_str        000158 0000d0
11      12     .debug_pubtypes   000228 000012
12      14     .shstrtab         00023a 000097
13      08     .rel.debug_info   00057c 000080
14      13     .rel.debug_pubtyp 0005fc 000008
15      15     .symtab           000604 000100
16      16     .strtab           000704 000030

Comment 2 Ulrich Drepper 2009-07-22 04:06:06 UTC
Patch checked in upstream.

Comment 3 Fedora Update System 2009-07-29 03:01:04 UTC
elfutils-0.142-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/elfutils-0.142-1.fc11

Comment 4 Fedora Update System 2009-07-29 03:01:19 UTC
elfutils-0.142-1.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/elfutils-0.142-1.fc10

Comment 5 Fedora Update System 2009-07-29 21:28:41 UTC
elfutils-0.142-1.fc10 has been pushed to the Fedora 10 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/F10/FEDORA-2009-8078

Comment 6 Fedora Update System 2009-07-29 21:29:32 UTC
elfutils-0.142-1.fc11 has been pushed to the Fedora 11 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/F11/FEDORA-2009-8083

Comment 7 Fedora Update System 2009-08-20 20:53:38 UTC
elfutils-0.142-1.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2009-08-20 20:58:57 UTC
elfutils-0.142-1.fc10 has been pushed to the Fedora 10 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.