From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102932 invoked by alias); 22 Oct 2019 14:29:02 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 102913 invoked by uid 89); 22 Oct 2019 14:29:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL,BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*MI:sk:87r23at X-HELO: EUR01-DB5-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=O5t7yq/jAweQbCyYVlIuHoP7z9qrLAVA5S/r5qo5GNg=; b=nuLZ/Y5MiXGSnsznfNN4eEVC9AEJU9tm/bJv8DGqQs1btqbO2f+4jKU9HYjbfMqvw30FYcH7DFtffqnjQSosmk0SmXTJOv4UuSg9aFLfjwrx0m1tHyBGT5kSX19fMI19yclRVaQpPOr4dklPm4IEaQzGeYRr/3YyCozNDcnKeko= 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-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kYN0gbpdye5dEsB9Esj75dKNpYfb8cboZ4YBsaozVrWYgtjC9AGAlG4VlvGjq/e5MipGRGTPIsO3Xzsbc+6dlqNCuaEVtU20uiPbsoB8dOCu3sLumFjVRx2JTP/2De4r90Fmb0GRye+sjMeL8UeERCxT7dpzFyrfGXM5HijK3G3+M81Tlh69S+lFZt4ppYFkrWln2Cz/wRva/JBKRFx2zCJZ3R2PNF+UKqNveUallZze9fKf2vs4pZGEbdUVY6wAc7Uz9onifBRHpIT1mqqAJcOQUinFOcxRdvpunZZbqXYSGxNRKudYOQ2NYx7nIr5pv275eJzdH4/3M+nJKWD3jQ== 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=O5t7yq/jAweQbCyYVlIuHoP7z9qrLAVA5S/r5qo5GNg=; b=UVZE0U+F9D4SJKQcPhozPy1lTXI+YmkdfZfuiBLeOsga3JLsTv0ten9XG1tNa5ecz9/su1lAfPgzxyRMuWg21lpfh0WAce7ADW/Gpdt/wFP3T8FnxYzz3QeI/v3wm7bPl2G2YNOy50r0/PzXust34N6JsfEfiCcK+eGouEeVrDoYA8V2TX/UPuJHWJPh/H5AyDyiODh3pTguboIyvfuofcS1m7kIhhWQh8p/5OYWo9/wNCrFFkGNtv8+qNKZVQKtkZqPHGtrIFczIpHoUypF2WIrjsnzL8QLLaaIYAO4EI1RCyBWnbQxxil8hURZyOd5cViwCNDR4YiPG4ozVcDymQ== 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=O5t7yq/jAweQbCyYVlIuHoP7z9qrLAVA5S/r5qo5GNg=; b=nuLZ/Y5MiXGSnsznfNN4eEVC9AEJU9tm/bJv8DGqQs1btqbO2f+4jKU9HYjbfMqvw30FYcH7DFtffqnjQSosmk0SmXTJOv4UuSg9aFLfjwrx0m1tHyBGT5kSX19fMI19yclRVaQpPOr4dklPm4IEaQzGeYRr/3YyCozNDcnKeko= From: David Kilroy To: Florian Weimer CC: "libc-alpha@sourceware.org" , nd Subject: RE: [PATCH 1/3] elf: Allow dlopen of filter object to work [BZ #16272] Date: Tue, 22 Oct 2019 14:29:00 -0000 Message-ID: References: <4eae391688a6e42b0b75467de265c122e6402668.1571301957.git.david.kilroy@arm.com> <87r23ath25.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87r23ath25.fsf@oldenburg2.str.redhat.com> x-ts-tracking-id: 449de09b-804a-4dc2-8640-1aa7ba1dfd97.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4636009)(396003)(346002)(136003)(376002)(39860400002)(366004)(189003)(199004)(476003)(86362001)(14454004)(446003)(478600001)(11346002)(256004)(316002)(33656002)(55016002)(229853002)(6916009)(486006)(6436002)(9686003)(74316002)(7736002)(305945005)(54906003)(99286004)(71200400001)(7696005)(66946007)(6116002)(102836004)(6506007)(2906002)(66066001)(8936002)(76176011)(8676002)(25786009)(52536014)(64756008)(66446008)(186003)(71190400001)(66556008)(26005)(4326008)(66476007)(81166006)(6246003)(81156014)(76116006)(3846002)(5660300002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB3619;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: jWWbhv4YmYHyCrE6g0/Cn0SrYxxY9ZspdrG9rAquEBU55QIKgK5S3K5CTU46n6gRLJMgygcUoFwqdRNea/mvmIumGh1Vcj0zQKb465ahpb3/TUQDAUI1aVpRWZC4lXF9RBEwDKKYxGSTqgJ2A0dKUGv2va05XRq70ugO4QKPgsTGgdmf18GfSOHXbaYgVuOhToJDuEvBfoaG8qeEq3A6YnAqVrn9IciylsWzDFHifC7sVOHIrcRVT9IhAL4SODZ4I0JHKfL3khQWucCQtA3De0l6ROZmqhbX38VBmG8nXwfioVagllZBidb1SkO+mi/sK3i0HTAj2HBjmBfXODoIi6H0ad2tZXDGXTH/0l2Lmq0KkCw6pQ6zh2abb7OH+JBiRwjNvChnwzR8/3N7d8ykn097XAxHNJNw1y4OxamYnsc= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; Return-Path: David.Kilroy@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5796502b-0c32-45bf-489f-08d756fc26ed X-SW-Source: 2019-10/txt/msg00659.txt.bz2 > Florian Weimer >=20 > * David Kilroy: >=20 > > diff --git a/elf/dl-open.c b/elf/dl-open.c index a9fd4cb..7fcfdc0 > > 100644 > > --- a/elf/dl-open.c > > +++ b/elf/dl-open.c > > @@ -305,22 +305,25 @@ dl_open_worker (void *a) > > allows IFUNC relocations to work and it also means copy > > relocation of dependencies are if necessary overwritten. */ > > unsigned int nmaps =3D 0; > > - struct link_map *l =3D new; > > + unsigned int j =3D 0; > > + struct link_map *l =3D new->l_initfini[0]; > > do > > { > > if (! l->l_real->l_relocated) > > ++nmaps; > > - l =3D l->l_next; > > + l =3D new->l_initfini[++j]; > > } > > while (l !=3D NULL); > > + /* Stack allocation is limited by the number of loaded objects. > */ > > struct link_map *maps[nmaps]; > > nmaps =3D 0; > > - l =3D new; > > + j =3D 0; > > + l =3D new->l_initfini[0]; > > do > > { > > if (! l->l_real->l_relocated) > > maps[nmaps++] =3D l; > > - l =3D l->l_next; > > + l =3D new->l_initfini[++j]; > > } > > while (l !=3D NULL); > > _dl_sort_maps (maps, nmaps, NULL, false); >=20 > I have much more trouble ascertaining whether this change is correct. > Are we certain that new->l_initfini is not a subset of the maps that > have been loaded? I've tried to double check this. Having not seen this code until recently, I may have some of the details wrong but I've to summarized what I think is the case below. In short, as far as I can tell all the libraries in the l_next list also ex= ist in l_initfini. If anyone knows otherwise, I'd appreciate a pointer. Regards, Dave. In dl_open_worker the field new->l_next is populated by _dl_map_object_from= _fd (via _dl_map_object), where it calls _dl_add_to_namespace_list. Every loaded object should be added to the global list. New->l_initfini is populated in _dl_object_map_deps() * The list `known` is populated with the binary, followed by preloads ** note: for the call from dlopen_worker, preloads is set to NULL * dependencies are added to `known` ** each dependency is opened (via openaux and _dl_map_object), so the l_next list contains all new dependencies. ** each dependency gets its own map->l_initfini populated * If the object is an aux or filter object ** the filtee is inserted before the filter in `known`. ** the l_next list is modified to put the filtee before the filter * l_initfini for the main binary is then redone (even if previously loaded) ** It gets each library in `known`, excluding those with l_faked set (library not found in trace mode) *** l_faked is only set to 1 in dl-load.c:_dl_map_object:2194 ** l_initfini is sorted. Note that the sort keeps the main object at the head of l_initfini, unlike the sort in _dl_open_worker