public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppluzhnikov at google dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/16046] New: dl_iterate_phdr should not expose internal stub
Date: Mon, 14 Oct 2013 20:34:00 -0000	[thread overview]
Message-ID: <bug-16046-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=16046

            Bug ID: 16046
           Summary: dl_iterate_phdr should not expose internal stub
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: ppluzhnikov at google dot com

Test case:

#define _GNU_SOURCE
#include <stdio.h>
#include <link.h>

int callback(struct dl_phdr_info *info, size_t size, void *data) {
  printf("addr=%p name=%s phdr=%p phnum=%d\n",
         (void*)info->dlpi_addr, info->dlpi_name, info->dlpi_phdr,
         info->dlpi_phnum);
  return 0;
}
int main() {
  int status;
  status = dl_iterate_phdr(callback, NULL);
  return 0;
}


Using current git trunk, dynamically linked binary shows:

addr=(nil) name= phdr=0x400040 phnum=9
addr=0x7fff2a613000 name=linux-vdso.so.1 phdr=0x7fff29d13040 phnum=4
addr=0x7f73a76d4000 name=./libc.so.6 phdr=0x7f73a76d4040 phnum=10
addr=0x7f73a7a87000 name=./elf/ld.so phdr=0x7f73a7a87040 phnum=7

Statically linked binary:

addr=(nil) name= phdr=0x400040 phnum=6
addr=(nil) name= phdr=(nil) phnum=0
addr=0x7ffffd5e1000 name=linux-vdso.so.1 phdr=0x7ffffcce1040 phnum=4

Same with glibc-2.15:
addr=(nil) name= phdr=0x400040 phnum=6


What is the second entry? People calling dl_iterate_phdr may legitimately
expect only real ELF images to appear.

At a minimum, this internal entry should be hidden from dl_iterate_phdr.

AFAICT, this was added in commit:

commit f91f1c0fb89056995f1c9c6a06c361efdf5139e7
Author: Maciej W. Rozycki <macro@codesourcery.com>
Date:   Fri Jun 28 16:20:26 2013 +0100

    [BZ #15022] Correct global-scope dlopen issues in static executables.

    This change creates a link map in static executables to serve as the
    global search list for dlopen.  It fixes a problem with the inability
    to access the global symbol object and a crash on an attempt to map a
    DSO into the global scope.  Some code that has become dead after the
    addition of this link map is removed too and test cases are provided.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2013-10-14 20:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 20:34 ppluzhnikov at google dot com [this message]
2013-10-14 20:35 ` [Bug dynamic-link/16046] " ppluzhnikov at google dot com
2014-01-31 18:03 ` cvs-commit at gcc dot gnu.org
2014-01-31 18:08 ` macro@linux-mips.org
2014-06-13  9:37 ` fweimer at redhat dot com
2014-06-20 20:55 ` cvs-commit at gcc dot gnu.org
2014-08-10 12:35 ` vapier at gentoo dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-16046-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).