[0/4] _r_debug copy relocation support

Message ID cover.1640284721.git.fweimer@redhat.com
Headers
Series _r_debug copy relocation support |

Message

Florian Weimer Dec. 23, 2021, 6:43 p.m. UTC
  I implemented this because we received a bug that the _r_debug extension
mechanism broke dyninst.  But it turns out it wasn't because of a copy
relocation: dyninst has its own interposing *definition* of _r_debug, so
the patch series doesn't solve this.  It can only handle an interposing
definition in the main executable, not one in shared object (although I
guess in theory we could fix this).

The first two patches are independently useful, and the second two
patches could be used if we ever need to implement copy relocation
support for _r_debug.

Tested on i686-linux-gnu and x86_64-linux-gnu.

Thanks,
Florian

Florian Weimer (4):
  elf: Introduce separate _r_debug_array variable
  elf: Introduce _dl_debug_change_state
  elf: Support version-less lookup in _dl_lookup_direct
  elf: Restore support for _r_debug copy relocations

 elf/Makefile               |   8 +++
 elf/dl-close.c             |   6 +-
 elf/dl-debug.c             | 138 ++++++++++++++++++++++++++-----------
 elf/dl-load.c              |   6 +-
 elf/dl-lookup-direct.c     |   5 ++
 elf/dl-open.c              |   5 +-
 elf/rtld.c                 |  10 +--
 elf/tst-dlmopen4-nonpic.c  |   2 +
 elf/tst-dlmopen4-pic.c     |   2 +
 elf/tst-dlmopen4.c         |  22 ++++++
 sysdeps/generic/ldsodefs.h |  27 ++++++--
 11 files changed, 168 insertions(+), 63 deletions(-)
 create mode 100644 elf/tst-dlmopen4-nonpic.c
 create mode 100644 elf/tst-dlmopen4-pic.c


base-commit: 9702a7901e18460e8ffc5f56a493d41294a8e936
  

Comments

H.J. Lu Dec. 23, 2021, 7:18 p.m. UTC | #1
On Thu, Dec 23, 2021 at 10:43 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> I implemented this because we received a bug that the _r_debug extension
> mechanism broke dyninst.  But it turns out it wasn't because of a copy
> relocation: dyninst has its own interposing *definition* of _r_debug, so
> the patch series doesn't solve this.  It can only handle an interposing
> definition in the main executable, not one in shared object (although I
> guess in theory we could fix this).

Why doesn't GDB suffer from this issue?

> The first two patches are independently useful, and the second two
> patches could be used if we ever need to implement copy relocation
> support for _r_debug.
>
> Tested on i686-linux-gnu and x86_64-linux-gnu.
>
> Thanks,
> Florian
>
> Florian Weimer (4):
>   elf: Introduce separate _r_debug_array variable
>   elf: Introduce _dl_debug_change_state
>   elf: Support version-less lookup in _dl_lookup_direct
>   elf: Restore support for _r_debug copy relocations
>
>  elf/Makefile               |   8 +++
>  elf/dl-close.c             |   6 +-
>  elf/dl-debug.c             | 138 ++++++++++++++++++++++++++-----------
>  elf/dl-load.c              |   6 +-
>  elf/dl-lookup-direct.c     |   5 ++
>  elf/dl-open.c              |   5 +-
>  elf/rtld.c                 |  10 +--
>  elf/tst-dlmopen4-nonpic.c  |   2 +
>  elf/tst-dlmopen4-pic.c     |   2 +
>  elf/tst-dlmopen4.c         |  22 ++++++
>  sysdeps/generic/ldsodefs.h |  27 ++++++--
>  11 files changed, 168 insertions(+), 63 deletions(-)
>  create mode 100644 elf/tst-dlmopen4-nonpic.c
>  create mode 100644 elf/tst-dlmopen4-pic.c
>
>
> base-commit: 9702a7901e18460e8ffc5f56a493d41294a8e936
> --
> 2.33.1
>
  
Florian Weimer Dec. 23, 2021, 7:59 p.m. UTC | #2
* H. J. Lu:

> On Thu, Dec 23, 2021 at 10:43 AM Florian Weimer via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> I implemented this because we received a bug that the _r_debug extension
>> mechanism broke dyninst.  But it turns out it wasn't because of a copy
>> relocation: dyninst has its own interposing *definition* of _r_debug, so
>> the patch series doesn't solve this.  It can only handle an interposing
>> definition in the main executable, not one in shared object (although I
>> guess in theory we could fix this).
>
> Why doesn't GDB suffer from this issue?

I expect that GDB uses DT_DEBUG, and that's not subject to
interposition, as before.

Thanks,
Florian
  
H.J. Lu Dec. 23, 2021, 8:47 p.m. UTC | #3
On Thu, Dec 23, 2021 at 11:59 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, Dec 23, 2021 at 10:43 AM Florian Weimer via Libc-alpha
> > <libc-alpha@sourceware.org> wrote:
> >>
> >> I implemented this because we received a bug that the _r_debug extension
> >> mechanism broke dyninst.  But it turns out it wasn't because of a copy
> >> relocation: dyninst has its own interposing *definition* of _r_debug, so
> >> the patch series doesn't solve this.  It can only handle an interposing
> >> definition in the main executable, not one in shared object (although I
> >> guess in theory we could fix this).
> >
> > Why doesn't GDB suffer from this issue?
>
> I expect that GDB uses DT_DEBUG, and that's not subject to
> interposition, as before.
>

Can dyninst also use DT_DEBUG?
  
Florian Weimer Dec. 23, 2021, 9 p.m. UTC | #4
* H. J. Lu:

> On Thu, Dec 23, 2021 at 11:59 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > On Thu, Dec 23, 2021 at 10:43 AM Florian Weimer via Libc-alpha
>> > <libc-alpha@sourceware.org> wrote:
>> >>
>> >> I implemented this because we received a bug that the _r_debug extension
>> >> mechanism broke dyninst.  But it turns out it wasn't because of a copy
>> >> relocation: dyninst has its own interposing *definition* of _r_debug, so
>> >> the patch series doesn't solve this.  It can only handle an interposing
>> >> definition in the main executable, not one in shared object (although I
>> >> guess in theory we could fix this).
>> >
>> > Why doesn't GDB suffer from this issue?
>>
>> I expect that GDB uses DT_DEBUG, and that's not subject to
>> interposition, as before.
>
> Can dyninst also use DT_DEBUG?

Not easily.  They can keep using _r_debug if they just remove their
local definition.

Thanks,
Florian
  
H.J. Lu Dec. 23, 2021, 9:50 p.m. UTC | #5
On Thu, Dec 23, 2021 at 1:00 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, Dec 23, 2021 at 11:59 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > On Thu, Dec 23, 2021 at 10:43 AM Florian Weimer via Libc-alpha
> >> > <libc-alpha@sourceware.org> wrote:
> >> >>
> >> >> I implemented this because we received a bug that the _r_debug extension
> >> >> mechanism broke dyninst.  But it turns out it wasn't because of a copy
> >> >> relocation: dyninst has its own interposing *definition* of _r_debug, so
> >> >> the patch series doesn't solve this.  It can only handle an interposing
> >> >> definition in the main executable, not one in shared object (although I
> >> >> guess in theory we could fix this).
> >> >
> >> > Why doesn't GDB suffer from this issue?
> >>
> >> I expect that GDB uses DT_DEBUG, and that's not subject to
> >> interposition, as before.
> >
> > Can dyninst also use DT_DEBUG?
>
> Not easily.  They can keep using _r_debug if they just remove their
> local definition.

DT_DEBUG is easily accessible.  I'd rather fix dyninst than add hacks
in ld.so.