Bug 1574923 - annobin: Confusing interspersed file-name symbols in .text section
Summary: annobin: Confusing interspersed file-name symbols in .text section
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: annobin
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-04 11:17 UTC by Florian Weimer
Modified: 2019-05-28 21:50 UTC (History)
2 users (show)

Fixed In Version: annobin-5.8-1.fc29
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2019-05-28 21:50:02 UTC
Type: Bug


Attachments (Terms of Use)

Description Florian Weimer 2018-05-04 11:17:57 UTC
Linking a program against a glibc which has been built with full annobin support results in this statically linked bits being copied over:

00000000004052c0 <__libc_csu_init>:
  4052c0:       41 57                   push   %r15

00000000004052c2 <elf_init.c>:
  4052c2:       49 89 d7                mov    %rdx,%r15
  4052c5:       41 56                   push   %r14
  4052c7:       49 89 f6                mov    %rsi,%r14
  4052ca:       41 55                   push   %r13
  4052cc:       41 89 fd                mov    %edi,%r13d
  4052cf:       41 54                   push   %r12
  4052d1:       4c 8d 25 c8 2a 20 00    lea    0x202ac8(%rip),%r12        # 607da0 <__frame_dummy_init_array_entry>
  4052d8:       55                      push   %rbp
  4052d9:       48 8d 2d d8 2a 20 00    lea    0x202ad8(%rip),%rbp        # 607db8 <__init_array_end>
  4052e0:       53                      push   %rbx
  4052e1:       4c 29 e5                sub    %r12,%rbp
  4052e4:       48 83 ec 08             sub    $0x8,%rsp
  4052e8:       e8 2b c2 ff ff          callq  401518 <_init>
  4052ed:       48 c1 fd 03             sar    $0x3,%rbp
  4052f1:       74 1b                   je     40530e <elf_init.c+0x4c>
  4052f3:       31 db                   xor    %ebx,%ebx
  4052f5:       0f 1f 00                nopl   (%rax)
  4052f8:       4c 89 fa                mov    %r15,%rdx
  4052fb:       4c 89 f6                mov    %r14,%rsi
  4052fe:       44 89 ef                mov    %r13d,%edi
  405301:       41 ff 14 dc             callq  *(%r12,%rbx,8)
  405305:       48 83 c3 01             add    $0x1,%rbx
  405309:       48 39 dd                cmp    %rbx,%rbp
  40530c:       75 ea                   jne    4052f8 <elf_init.c+0x36>
  40530e:       48 83 c4 08             add    $0x8,%rsp
  405312:       5b                      pop    %rbx
  405313:       5d                      pop    %rbp
  405314:       41 5c                   pop    %r12
  405316:       41 5d                   pop    %r13
  405318:       41 5e                   pop    %r14
  40531a:       41 5f                   pop    %r15
  40531c:       c3                      retq   
  40531d:       0f 1f 00                nopl   (%rax)

The elf_init.c symbol looks very much out of place.

I believe this is the command line used to compile elf-init.c:

gcc elf-init.c -c -std=gnu11 -fgnu89-inline  -O2 -Wa,--generate-missing-build-notes=yes -Wall -Werror -Wundef -Wwrite-strings -fasynchronous-unwind-tables -fmerge-all-constants -frounding-math -fstack-clash-protection -fstack-protector-strong -g -m64 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wstrict-prototypes -Wold-style-definition -fno-math-errno   -fpie -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0 -fPIC   -ftls-model=initial-exec      -I../include -I/builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux/csu  -I/builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/8/include -isystem /usr/include  -D_LIBC_REENTRANT -include /builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DPIC -DLIBC_NONSHARED=1     -DTOP_NAMESPACE=glibc -o /builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux/csu/elf-init.oS -MD -MP -MF /builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux/csu/elf-init.oS.dt -MT /builddir/build/BUILD/glibc-2.27.9000-326-g0085be1415/build-x86_64-redhat-linux/csu/elf-init.oS

Comment 1 Florian Weimer 2018-05-04 11:26:42 UTC
We also have this:

0000000000401c71 <static_reloc.c_end>:
  401c71:       66                      data16

0000000000401c72 <static_reloc.c>:
  401c72:       2e 0f 1f 84 00 00 00    nopl   %cs:0x0(%rax,%rax,1)
  401c79:       00 00 
  401c7b:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)

This confuses eu-checksec:

Hardened: eu-checksec: GAP detected in annobin notes: 401c72 .. 401d30.

Comment 2 Nick Clifton 2018-05-04 14:28:20 UTC
Hi Florian,

> Linking a program against a glibc which has been built with full annobin
> support results in this statically linked bits being copied over:
> 
> 00000000004052c0 <__libc_csu_init>:
>   4052c0:       41 57                   push   %r15
> 
> 00000000004052c2 <elf_init.c>:
>   4052c2:       49 89 d7                mov    %rdx,%r15

> The elf_init.c symbol looks very much out of place.

This happens because annobin now creates a start-of-file symbol that is
actually two bytes in from the start of the file.  This is on the
assumption that this offset will prevent the symbol from overlapping the
function symbol for the first function in the file, and so stop the
problems associated with having two symbols for the same address.

Is the presence of this symbol merely an inconvenience, or is it actually
breaking something ?  Apart from the disassembler output that is, which I
agree is wrong.

One thing I could try is to move the annobin file start symbol two bytes
prior to the start of the file...  Although this might cause problems with
the end of the disassembly of the code that is prior to elf_init.c in the
application's address space. :-(


(In reply to Florian Weimer from comment #1)
> We also have this:
> 
> 0000000000401c71 <static_reloc.c_end>:
>   401c71:       66                      data16
> 
> 0000000000401c72 <static_reloc.c>:
>   401c72:       2e 0f 1f 84 00 00 00    nopl   %cs:0x0(%rax,%rax,1)

Hang on - how did the end-of-file symbol end up being before the
start-of-file symbol ?


> This confuses eu-checksec:

Well yes, I am confused too.  Is there something funky going on in the
source for static_reloc.c ?  Some section pushing and popping maybe ?

Cheers
  Nick

Comment 3 Florian Weimer 2018-05-04 14:44:05 UTC
(In reply to Nick Clifton from comment #2)
> (In reply to Florian Weimer from comment #1)
> > We also have this:
> > 
> > 0000000000401c71 <static_reloc.c_end>:
> >   401c71:       66                      data16
> > 
> > 0000000000401c72 <static_reloc.c>:
> >   401c72:       2e 0f 1f 84 00 00 00    nopl   %cs:0x0(%rax,%rax,1)
> 
> Hang on - how did the end-of-file symbol end up being before the
> start-of-file symbol ?

I think it's because the end symbol is not biased, only the start symbol.

The biasing looks wrong to me because it makes the covered PC range incorrect.

> Well yes, I am confused too.  Is there something funky going on in the
> source for static_reloc.c ?  Some section pushing and popping maybe ?

Not really, as far as I can see, it is just an empty file, or maybe it contains a single empty function (not sure about the compiler flags here).  I can reproduce it with small input files:

    38: 00000000004004e3     0 NOTYPE  LOCAL  DEFAULT   12 m.c
    39: 00000000004004e1     0 NOTYPE  LOCAL  DEFAULT   12 m.c_end

$ cat m.c
main() { }

That's wrong on a different level because the main function is *outside* this range:

    77: 00000000004003e0     3 FUNC    GLOBAL DEFAULT   12 main

> Is the presence of this symbol merely an inconvenience, or is it actually
> breaking something ?  Apart from the disassembler output that is, which I
> agree is wrong.

It's worse if the symbol is in the middle of the instruction because it can happen that this corrupts the disassembler output.

Comment 4 Nick Clifton 2018-05-14 16:44:55 UTC
I have added a patch to the rawhide annobin which appears to resolve this
problem.  (By making the annobin file symbol hidden).  I would like to leave
it a few days however before backporting to F28, just to make sure that it
really does work, and that it does not break anything.

Fixed in: annobin-5.8-1.fc29

Comment 5 Ben Cotton 2019-05-02 19:22:51 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Ben Cotton 2019-05-02 21:19:44 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2019-05-28 21:50:02 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.