bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/20815] New: throw errors for invalid load segment


From: ma.jiang at zte dot com.cn
Subject: [Bug ld/20815] New: throw errors for invalid load segment
Date: Mon, 14 Nov 2016 07:07:12 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=20815

            Bug ID: 20815
           Summary: throw errors for invalid load segment
           Product: binutils
           Version: 2.28 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: ma.jiang at zte dot com.cn
  Target Milestone: ---

Created attachment 9628
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9628&action=edit
files to reproduce the bug, and the fix.

When doing some hugepage tests, I found gnu-ld would create a wrong elf when
giving a wrong linker script.
  On a x86-64 machine, using attached demo could reproduce this bug ,just "gcc
test.c pad.ld -o test". The generated "test" will receive a segv when
staring(on a linux platform).
  The core problem is that ld create a segment for the faked section in
"pad.ld", and this segment become the first load segment as the faked section
has the lowest address. However, per the ELF specification, the first load
segment should contain program headers. The linux kernel only try to find
program headers in the first load segment as well. All together, when staring
the generated "test", the kernel will put a wrong addr into AT_PHDR. Finally,
the dynamic loader trigger the segv fault when accessing program headers at
AT_PHDR.
  Of course, the root cause of this problem is "pad.ld" which breaks the ELF
specification. But gnu-ld should stop creating output files and print warnings.
  Attached "segment-check.patch" adds a check in make_mapping(in elf.c) , it
should be enough to fix the bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]