From patchwork Thu Oct 17 10:33:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1178449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106055-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OwiBc3E8"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="+Jj6tpAQ"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="+Jj6tpAQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46v59h3V7cz9sNx for ; Thu, 17 Oct 2019 21:33:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=wxfwiROrMgPy0w+ynwiVq+HXcA4asRpQ1SgBVd4oFk/22HVVsvsIu nQTJG0a6PKbKepOWEQ+DGgAqyoLqLuaXRKFIIC8blWNvKOtz2VqLLP6c/F5DTrG7 q0tPRI3WMoQCxt3LbhfoUjQMlF2Qf+yLZ7+P4la5Pqqp3YGzwypxI8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :content-type:content-transfer-encoding:mime-version; s=default; bh=NZQF0ud7SsPAvQaECKH2AukgNNs=; b=OwiBc3E8U0jgpX76uwVJ2cQcGKY0 Z046L47fkaUJX1sRXFmBjmCozsPa6+lvA3Uq4e+sol8glB1P6mEXa/CKBJYpj3mI 28eBWF7p2SZlGoXFvYRtq8gdyGFQ2laWsPs/fA048UyvJqu+6VUobqXPo/D96AF0 9QL2qaF/CKvYuRI= Received: (qmail 57130 invoked by alias); 17 Oct 2019 10:33:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 57110 invoked by uid 89); 17 Oct 2019 10:33:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL, BAYES_00, FORGED_SPF_HELO, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t0ICEtP1nMYU8HmwanTRO7LaLbn68khs+TTJenx/dSs=; b=+Jj6tpAQm5FGHf2hQLXTHyNwYeb5nbnpOdonCkxPPS2CSTpJpv7yAV2VRaToUa7zAFiCvsDM2CItpYiaqWE8WgiPCqJwXHU0RFiR96ktTJsbUqzqaihqH0iFpYhYXOpRvye3I8Epj9DMWL+SMmNVVgFOVTncYV2hvkiqvNhETEQ= Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=none action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-CheckRecipientChecked: true X-CR-MTA-CID: fae7c82ff4ebf975 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SoPNdjH7l0No2uwCtgiRzYzG4aX4toSRpg3s2qkRGoTA9UgGZa0VNuE786AdnWcS9Z0fHAL6G7sZz66DsgKyeiEJfmiXmmLpYCLUOveNru0Agr7eA/X4fD5nsatzdhiIdxWUN2pM3OG+EtrU1QNOKpsarXfX8f5i/8sUMP9xQbfwN+tOxYjhbSFAFnse2jUo+nhxI6tEOw5Qbu84++TsRIKvBdzuyGx2jq55e6BXbftRB5o2yEvloiBGhUQ7NjIdDYxMUPYw3RF0aJmGHRzjPAQwoBqlCpCd046zb4pOQs+8aJ8yd1tz7TR95Yp9QRWqlc+HewEZLbfQKZFDpkMN7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t0ICEtP1nMYU8HmwanTRO7LaLbn68khs+TTJenx/dSs=; b=avAw3XhOgMdaGuzYo3rBmcCBTpgAWVG2EyEcEUy5xtyvREyh7TKn1gGyPMO/q6jSqQGElnUfSoOUMODLsJIgat5vXl6UWb8t+cHx7lpKOya700EP/R4hJSxtZcn62PoQ7vMJ3c9PSIZIHCqQpLGWRoVAgyC4QJjRBATgB+vPl89bIxZMMuxVTotONdcwuNjEyS0xrt6Xs5yPVel1cenev/m8Vloo9860ANDShMl13TX3X7+tia2Sj/miczGqD7R+AxJWCDKdjhiENpioF4tgXHXYW6EsH50krGv804A2Twe07eFakKxavwJ/doCL0p4RIQnOZF3KrESsnOKsEXRybg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t0ICEtP1nMYU8HmwanTRO7LaLbn68khs+TTJenx/dSs=; b=+Jj6tpAQm5FGHf2hQLXTHyNwYeb5nbnpOdonCkxPPS2CSTpJpv7yAV2VRaToUa7zAFiCvsDM2CItpYiaqWE8WgiPCqJwXHU0RFiR96ktTJsbUqzqaihqH0iFpYhYXOpRvye3I8Epj9DMWL+SMmNVVgFOVTncYV2hvkiqvNhETEQ= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 0/3] elf: Allow dlopen of filter object to work [BZ #16272] Date: Thu, 17 Oct 2019 10:33:18 +0000 Message-ID: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(136003)(39860400002)(396003)(346002)(189003)(199004)(7736002)(305945005)(64756008)(99286004)(478600001)(66946007)(36756003)(102836004)(66446008)(66556008)(6512007)(26005)(186003)(386003)(66476007)(5640700003)(71200400001)(2501003)(44832011)(486006)(2616005)(5660300002)(476003)(52116002)(8676002)(71190400001)(66066001)(4326008)(6506007)(6436002)(86362001)(8936002)(3846002)(25786009)(6116002)(14454004)(81166006)(6916009)(6486002)(316002)(256004)(81156014)(14444005)(2906002)(50226002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB5492; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ESd7SQ+s0HYOnfH7vrFiWeJRTSuYBVXXLeIpKDt3e9/GsdDSAZ201VfDKOmYNxqAVRRHfTtqB5FwK1b+eIiANAKI94+fcaIsblE9l42lKoQlxwZLD5tovq/rFAyZ8M2pADhO8eiatSboS5azq3Sm+FTREfxHJLpet5FiBsSIkxiqVG0RJnbbJYVlSO0Z6uJzIy23KX81d/uEZTMkPvknOn0L58XRKZU7byftRsNKchIxJcOH+gQbMq9M4+NJUAM578/mHVz5jhxGxT96VNfemVS7z8yaVD6hkWKfBYgGB3Xy99GKYhh+GaIgHQNYwRh+Gt/bCC27QrRExB1B95xNZpqiISHhM1YTXook8hAgxwK8UXXFXeFb0fEOdZ9OHzqlC6xu0kBonn2+aQAA6aDw2spqmOyWa7mT/bEIBPcBkO8= x-ms-exchange-transport-forked: True MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4444e4fa-7d1d-48e4-40f7-08d752ed6cef Glibc currently supports filter objects (shared libraries compiled with -Wl,--filter) by inserting the filtee ahead of the filter object in the search path. This works for the case where the application is linked against the filter object. When the application tries to use dlopen to load the filter object, glibc currently fails with: Inconsistency detected by ld.so: dl-deps.c: 574: _dl_map_object_deps: Assertion `map->l_searchlist.r_list[0] == map' failed! This fails because dl_map_object_deps assumes that the library being loaded is at the head of the search list. The filtee object also needs to be relocated when dlopen is used. The first patch attempts to address these in a minimal way, and adds a test case verify the fix. The follow up patches do some cleanup. If we can use l_initfini to do the relocations, then the call to _dl_sort_maps is redundant. Once that is removed there is no need for the stack allocation of map. David Kilroy (3): elf: Allow dlopen of filter object to work [BZ #16272] elf: avoid redundant sort in dlopen elf: avoid stack allocation in dl_open_worker elf/Makefile | 12 +++++++++-- elf/dl-deps.c | 35 ++++++++++++++++++++++-------- elf/dl-open.c | 32 +++++++++++++-------------- elf/tst-filterobj-dlopen.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ elf/tst-filterobj-flt.c | 24 +++++++++++++++++++++ elf/tst-filterobj-lib.c | 24 +++++++++++++++++++++ elf/tst-filterobj-lib.h | 18 ++++++++++++++++ elf/tst-filterobj.c | 34 +++++++++++++++++++++++++++++ 8 files changed, 205 insertions(+), 28 deletions(-) create mode 100644 elf/tst-filterobj-dlopen.c create mode 100644 elf/tst-filterobj-flt.c create mode 100644 elf/tst-filterobj-lib.c create mode 100644 elf/tst-filterobj-lib.h create mode 100644 elf/tst-filterobj.c