From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13727 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: dlsym(handle) may search in unrelated libraries Date: Thu, 7 Feb 2019 21:37:32 +0100 Message-ID: <20190207203732.GH5469@voyager> References: <20190206160248.GB5469@voyager> <20190206202518.GC5469@voyager> <96c367533236e3e203f04a994ee65c47@ispras.ru> <20190207053327.GD5469@voyager> <8031d662-bf4f-1321-155c-942a8c92e1d8@ispras.ru> <20190207174312.GE5469@voyager> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="HnQK338I3UIa/qiP" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="101573"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: musl@lists.openwall.com To: Alexey Izbyshev Original-X-From: musl-return-13743-gllmg-musl=m.gmane.org@lists.openwall.com Thu Feb 07 21:38:39 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1grqRT-000QIK-5q for gllmg-musl@m.gmane.org; Thu, 07 Feb 2019 21:38:39 +0100 Original-Received: (qmail 20275 invoked by uid 550); 7 Feb 2019 20:38:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 20257 invoked from network); 7 Feb 2019 20:38:36 -0000 Content-Disposition: inline In-Reply-To: <20190207174312.GE5469@voyager> X-Provags-ID: V03:K1:9IyddjWpvieBB7Z/K0Ase52alu25PPoWfuycCIjIHyum/hhpe8Z QrKRqcNndbE+lKxqXsBMrq6fiUWb3nDGZVGUlJ9dVDLVFHYdxaBsrjvsRBRxnlVAvggJFdZ 4/UUVykG/W9C4eYUcZg6PA2jmvrfLAGGx6EAHKVOe0mD5KwWYSyzxZjdgTUL6sAzxfGdiGd AijOLaSObiDqRMf/RBjuw== X-UI-Out-Filterresults: notjunk:1;V03:K0:kOz/4c3ZxFY=:/hHFG0dO2GCQKGOCkN38yC vv+5loJl8TXJOjyniY2dTI7TBXwt4EZQflxBMArHIpx0UxBBhqESwlXnnP1OVB7JGia4BZNBI smqxYtZ7tUzO0uKBtRyPxA7NH8TRogjCHG4+sEmiol5fe98l/B+ehODEsVb1hcBTOPao3fSTZ oDobDyKUg0HRboZkNewXaw+5cerDhsYUSX0W5bTN1vPqx3ibVksTud030wO5JW/TgIdMPsvf2 qsKre0SdQlpKYV1qag/C0+A5yfhUjecoZUZ1r54bATZCpU/rBPnnYc4hblVlT24BJDe9UnL3K JEXdbeLHzMgQDf7l5+qCn/VehNOGzTRU6axoJ0jRMFuqFisie+Xvl6H3ZiqT84cXZ8oArqapo uLTHgZyN1OuTqwEwzkwADgOpYtQFJJLnucTA5p2kpYLK6xVQsb2+rZRfbb7tcjD64yiKS5veh xHhXZdrFrLgAYQZDtb+PlbFn94QrnGPlZazbPLgVtaETsFAXwuXvpoh8rMuaKXT9T7YihgjDQ vVU388fwtyTl/mrz1tVOIiU7pz1u81uUfpy5Ufxz3Ge+iWeIrqha7WN/Gyi2m9LsjOT0X9ay2 lBu/Y2V18svDhc0dFBPPTrZ9jWeYUZsZPeqzLWBhzzfiH6mJLd6da3Xnc3UKoiDayptpgCd/Y 2CjrAdEwPVck3X1zQDcQJqmZ2wzeOXGm+QtXxNCoydoeN9al0lvnvycPv9YHdsotdWX/DaZlG Khl4E+bsh/ssO4Z4M7e34Yr9tKKxClTQjD1A9cn+IJySYEwrRy0G7UOVEAk4F2YAvNJL+fDd Xref: news.gmane.org gmane.linux.lib.musl.general:13727 Archived-At: --HnQK338I3UIa/qiP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --HnQK338I3UIa/qiP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0010-Fix-crash-bug-from-previous-commit.patch" >From d90e719cccfe09439324b66cd8894d3781b00048 Mon Sep 17 00:00:00 2001 From: Markus Wichmann 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 --HnQK338I3UIa/qiP--