From patchwork Mon Mar 30 17:43:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: develop--- via Libc-alpha X-Patchwork-Id: 1264174 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=daHClRXL; dkim-atps=neutral Received: from sourceware.org (unknown [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rfxB4L4Fz9sPR for ; Tue, 31 Mar 2020 04:45:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F7EE388A00D; Mon, 30 Mar 2020 17:44:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F7EE388A00D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1585590247; bh=2suSpy7M634pFEJ8Rnsx7z4pRj1mF/6oWBGJRorowlc=; h=To:Subject:Date:In-Reply-To:References:In-Reply-To:References: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:From:Reply-To:From; b=daHClRXLoQwWzW071Tdp0ro8mw4PeCmVreM6QBVUWdmzwhz6ntoUJgm3pqkEKqONc nzQKZ7YhasouflIoLDisQdFDBQxHXYEspCzXVscFugpcDVJhqisjsxJU1oCKCNzlBB 169d/skUipHWr6gCXrsrnfPTETZ9NJII2zZaCyiY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 0A7EF385F024 for ; Mon, 30 Mar 2020 17:44:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A7EF385F024 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 4839D2966FD; Mon, 30 Mar 2020 18:43:58 +0100 (BST) To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH v4 11/15] Use the DSO search helper to check for preloaded DF_1_UNIQUE DSOs Date: Mon, 30 Mar 2020 18:43:45 +0100 Message-Id: <53ddc0d7ea9da7df9bab1cc47e0150223cf2bf3d.1585588166.git.vivek@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-27.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra_via_Libc-alpha?= From: develop--- via Libc-alpha Reply-To: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" If a DSO already exists (with the same name) in the base namespace and it is flagged DF_1_UNIQUE then we should behave as if a proxy had been requested. --- elf/dl-open.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/elf/dl-open.c b/elf/dl-open.c index 9265b4239a..0197cd07e0 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -476,6 +476,7 @@ dl_open_worker (void *a) const char *file = args->file; int mode = args->mode; struct link_map *call_map = NULL; + struct link_map *preloaded = NULL; int want_proxy = mode & RTLD_SHARED; Lmid_t proxy_ns = LM_ID_BASE; @@ -510,6 +511,22 @@ dl_open_worker (void *a) may not be true if this is a recursive call to dlopen. */ _dl_debug_initialize (0, args->nsid); + /* Target Lmid is not the base and we haven't explicitly asked for a proxy: + We need to check for a matching DSO in the base Lmid in case it is flagged + DF_1_UNIQUE in which case we add RTLD_SHARED to the mode and set + want_proxy. */ + if (__glibc_unlikely (args->nsid != LM_ID_BASE) && + __glibc_likely (!want_proxy)) + { + preloaded = _dl_find_dso (file, LM_ID_BASE); + + if (preloaded && (preloaded->l_flags_1 & DF_1_UNIQUE)) + { + want_proxy = RTLD_SHARED; + mode |= RTLD_SHARED; + } + } + /* Load the named object. */ struct link_map *new; args->map = new = _dl_map_object (call_map, file, lt_loaded, 0,