This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Skip PT_DYNAMIC segment if its p_filesz == 0 [BZ #22101]


On 09/25/2017 06:33 PM, H.J. Lu wrote:
> ELF object generated with "objcopy --only-keep-debug" has
> 
> Type     Offset  VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
> DYNAMIC  0x0+e28 0x0+200e40 0x0+200e40 0x0+    0x0+1a0 RW  0x8
> 
> with 0 file size. ld.so should skip such PT_DYNAMIC segments.
> 
> Tested on x86-64.  OK for master?

Are all such `objcopy --only-kee--debug` objects left with 0 file size?

After your patch what happens when you run ldd on such an object?

The idea in bug 22101 is to add minimal code early in the dynamic
loader to identify specially marked objects and ignore them. This
way we put an end to the guessing game of what constitutes a valid
ELF object.

Granted, the code you've added is quite small, so it looks like
an interesting short term solution. It needs a more verbose
comment for the PT_DYNAMIC case explaining why we check if
ph->p_filesz is zero and what the consequences of that are since
we *never* add such defensive checks in ld.so because they would
slow down the average case of a correctly formed binary (and
thus need a hefty comment).

-- 
Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]