mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: dlsym(handle) may search in unrelated libraries
Date: Thu, 7 Feb 2019 21:37:32 +0100	[thread overview]
Message-ID: <20190207203732.GH5469@voyager> (raw)
In-Reply-To: <20190207174312.GE5469@voyager>

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

I accidentally added a crash. Namely exactly here:

> +static void load_deps_runtime(struct dso *p)
> +{
> +	size_t i, ndeps=0, j=0;
> +	struct dso ***deps = &p->deps, **tmp, *dep;
> +	for (; p; p=(*deps)[j++]) {

*deps might be null pointer, which this expression is dereferencing.
Patch is attached.

Ciao,
Markus

[-- Attachment #2: 0010-Fix-crash-bug-from-previous-commit.patch --]
[-- Type: text/x-diff, Size: 983 bytes --]

From d90e719cccfe09439324b66cd8894d3781b00048 Mon Sep 17 00:00:00 2001
From: Markus Wichmann <nullplan@gmx.net>
Date: Thu, 7 Feb 2019 21:35:17 +0100
Subject: [PATCH 10/10] Fix crash bug from previous commit.

The previous revision would crash if dlopen() was called for a library
with no dependencies.
---
 ldso/dynlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 66e6f18b..85c3db75 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1136,7 +1136,8 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
 	return p;
 }
 
-static void load_deps_loadtime(struct dso *p) {
+static void load_deps_loadtime(struct dso *p)
+{
 	size_t i;
 	struct dso *dep;
 	p->deps = (struct dso**)&nodeps_dummy;
@@ -1171,6 +1172,7 @@ static void load_deps_runtime(struct dso *p)
 			tmp[ndeps] = 0;
 			*deps = tmp;
 		}
+		if (!*deps) break;
 	}
 	if (!*deps) *deps = (struct dso**)&nodeps_dummy;
 }
-- 
2.20.1


  reply	other threads:[~2019-02-07 20:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 21:02 Alexey Izbyshev
2019-02-06 13:40 ` Alexey Izbyshev
2019-02-06 16:02 ` Markus Wichmann
2019-02-06 17:02   ` Alexey Izbyshev
2019-02-06 20:25     ` Markus Wichmann
2019-02-06 21:23       ` Alexey Izbyshev
2019-02-07  5:33         ` Markus Wichmann
2019-02-07 13:42           ` Alexey Izbyshev
2019-02-07 17:43             ` Markus Wichmann
2019-02-07 20:37               ` Markus Wichmann [this message]
2019-02-07 21:29               ` Rich Felker
2019-02-07 16:54           ` Rich Felker
2019-02-07 18:36             ` Markus Wichmann
2019-02-07 18:57               ` Rich Felker
2019-02-07 20:31                 ` Markus Wichmann
2019-02-07 21:33                   ` Rich Felker
2019-02-07 21:37                     ` Rich Felker
2019-02-08 10:19             ` A. Wilcox
2019-02-08 12:00               ` Szabolcs Nagy
2019-02-08 16:09                 ` Rich Felker
2019-02-09 22:53 Alexey Izbyshev
2019-02-10  1:03 ` Rich Felker
2019-02-26 15:07   ` Rich Felker
2019-03-04  2:11     ` Rich Felker

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=20190207203732.GH5469@voyager \
    --to=nullplan@gmx.net \
    --cc=izbyshev@ispras.ru \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).