This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Seeking advice on writing a test [Re: [patch] Fix BZ 20419 -- stack overflow with huge PT_NOTE segment]
On Mon, May 7, 2018 at 5:01 AM Florian Weimer <fweimer@redhat.com> wrote:
> On 05/06/2018 08:17 PM, Paul Pluzhnikov wrote:
> > An ELF binary with 131072 Phdrs is unlikely to happen in practice,
except
> > in some kind of exploit.
It turns out that e_phnum is a 16-bit entity, so the max value it could
have is 65535, which yields only 3.5MiB.
I wrote a program to generate DSO with that many Phdr[]s, and confirmed
that "ld.so --list foo.so" passes with default 8MiB stack, but crashes with
anything below 6600KiB with SIGSEGV due to stack overflow.
I think it's reasonable to expect "ld.so --list foo.so" to be able to run
successfully with 1MiB (or even 128K) stack.
My generator program is mostly machine independent, except it needs to set
e_ident[EI_DATA] and e_machine appropriately.
The easiest approach is to put this program and the test into
sysdeps/x86_64 and make this x86_64-only test. Would that be acceptable?
Alternatively, sysdeps/*/dl-machine.h could supply __ELF_NATIVE_MACHINE and
__ELF_NATIVE_DATA_ENCODING (similar to __ELF_NATIVE_CLASS defined in
bits/elfclass.h), which the program can then use to set e_machine etc.
appropriately.
Advice?
Thanks,
--
Paul Pluzhnikov