Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 18 Jul 2018 21:38:34 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: Re: Segmentation fault in static binaries built with
 recent binutils

* Szabolcs Nagy <nsz@...t70.net> [2018-07-18 21:00:24 +0200]:

> * Reiner Herrmann <reiner@...ner-h.de> [2018-07-18 20:14:38 +0200]:
> > > Can you attach a readelf -a of the binary that's crashing?
> > 
> > The output is attached.
> 
> i could reproduce the crash in a debian:unstable docker image
> 
> i see incorrect auxv[AT_PHDR] value, not yet sure why.
> 
> 
> Program received signal SIGSEGV, Segmentation fault.
> static_init_tls (aux=aux@...ry=0x7fffffffebc0) at ../src/env/__init_tls.c:88
> 88			if (phdr->p_type == PT_PHDR)
> (gdb) disas
> Dump of assembler code for function static_init_tls:
>    0x0000000000401404 <+0>:	sub    $0x8,%rsp
>    0x0000000000401408 <+4>:	mov    0x18(%rdi),%r9
>    0x000000000040140c <+8>:	mov    0x28(%rdi),%rsi
>    0x0000000000401410 <+12>:	xor    %ecx,%ecx
>    0x0000000000401412 <+14>:	xor    %eax,%eax
>    0x0000000000401414 <+16>:	mov    %r9,%rdx
>    0x0000000000401417 <+19>:	test   %rsi,%rsi
>    0x000000000040141a <+22>:	je     0x401456 <static_init_tls+82>
> => 0x000000000040141c <+24>:	mov    (%rdx),%r8d
> ...
> (gdb) p/x aux[3]
> $4 = 0x400040
> (gdb) i proc map
> process 13499
> Mapped address spaces:
> 
>           Start Addr           End Addr       Size     Offset objfile
>             0x401000           0x402000     0x1000     0x1000 /musl/build/a.out
>             0x402000           0x403000     0x1000     0x2000 /musl/build/a.out
>             0x403000           0x405000     0x2000     0x2000 /musl/build/a.out
>       0x7ffff7ffa000     0x7ffff7ffd000     0x3000        0x0 [vvar]
>       0x7ffff7ffd000     0x7ffff7fff000     0x2000        0x0 [vdso]
>       0x7ffffffde000     0x7ffffffff000    0x21000        0x0 [stack]


seems like another musl-gcc wrapper issue, if i do the linking
manually then i get a working binary, havent yet figured out why

manual linking:

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x000000 0x0000000000400000 0x0000000000400000 0x0001ec 0x0001ec R   0x1000
  LOAD           0x001000 0x0000000000401000 0x0000000000401000 0x0005a4 0x0005a4 R E 0x1000
  LOAD           0x002000 0x0000000000402000 0x0000000000402000 0x00004c 0x00004c R   0x1000
  LOAD           0x002ff0 0x0000000000403ff0 0x0000000000403ff0 0x000018 0x0002a8 RW  0x1000
  NOTE           0x0001c8 0x00000000004001c8 0x00000000004001c8 0x000024 0x000024 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x10
  GNU_RELRO      0x002ff0 0x0000000000403ff0 0x0000000000403ff0 0x000010 0x000010 R   0x1

musl-gcc linking:

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0x0000000000401000 0x0000000000401000 0x0005a4 0x0005a4 R E 0x1000
  LOAD           0x002000 0x0000000000402000 0x0000000000402000 0x00004c 0x00004c R   0x1000
  LOAD           0x002ff0 0x0000000000403ff0 0x0000000000403ff0 0x000018 0x0002a8 RW  0x1000
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x10
  GNU_RELRO      0x002ff0 0x0000000000403ff0 0x0000000000403ff0 0x000010 0x000010 R   0x1

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.