public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sware at reimardoeffinger dot de" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/27105] New: dlmopen crashes if library does not depend on libc
Date: Tue, 22 Dec 2020 12:45:21 +0000	[thread overview]
Message-ID: <bug-27105-131@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 27105
           Summary: dlmopen crashes if library does not depend on libc
           Product: glibc
           Version: 2.32
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: sware at reimardoeffinger dot de
  Target Milestone: ---

This code in dl-open.c assumes a libc is loaded:
  if (!args->libc_already_loaded)
    {
      struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
#ifdef SHARED
      bool initial = libc_map->l_ns == LM_ID_BASE;

(i.e. there is no check for libc_map being NULL)
However there seems to be no code that ensures this, and if dlmopen is used
this can easily be the case.

Trivial script to reproduce the issue:

#!/bin/bash
echo 'void dummytestfunc(void) {}' | gcc -o dummy.so -shared -Os -nostdlib -x c
-
gcc -o test -Os -x c - -ldl <<EOF
#define _GNU_SOURCE
#include <dlfcn.h>
int main()
{
    dlmopen(LM_ID_NEWLM, "./dummy.so", RTLD_NOW);
    return 0;
}
EOF
./test

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

                 reply	other threads:[~2020-12-22 12:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-27105-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).