From patchwork Wed Dec 20 13:42:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 851476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88432-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="QUct7SpQ"; 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 3z1wvq14kmz9s7f for ; Thu, 21 Dec 2017 00:43:18 +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:date:from:to:subject:message-id:mime-version :content-type:content-transfer-encoding:in-reply-to; q=dns; s= default; b=ElONLxcAElwmHDdWy6jiLCzs2oCYRAXlFkVyx63K8HWQqBKzK7kQT OMPqw58TMARIYxFMjTQThZbyqtG3x4jlUFUPX011LjrKhENalg47xiHz0xXrkc9Q RFBtCCJARbxcEMmdHA/MoyF2D4jXCWO7AIQzGpOnQPVj9/jQskI+D8= 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:date:from:to:subject:message-id:mime-version :content-type:content-transfer-encoding:in-reply-to; s=default; bh=avzKxe5PdjY5jz+I/tGpjmVDy9c=; b=QUct7SpQdE3AX2rbx5eQc/rLgcQ/ r0c1jZm87jlD4ejAHTBaK7P95F/ukma2V4pLG7S2YmfQsXq7WVaS0Wx0xcrQSvei MjYaCBKp37MO7mGbwl875++tDm/GAfkzoNbD5qDKZhR/wufPqrCOyZo+JOjhi3lv ht0n14KCas8jBCs= Received: (qmail 27679 invoked by alias); 20 Dec 2017 13:42:54 -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 27654 invoked by uid 89); 20 Dec 2017 13:42:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1870 X-HELO: vmicros1.altlinux.org Date: Wed, 20 Dec 2017 16:42:50 +0300 From: "Dmitry V. Levin" To: libc-alpha@sourceware.org Subject: [PATCH 1/3] elf: remove redundant code from _dl_dst_substitute Message-ID: <20171220134250.GD20476@altlinux.org> Mail-Followup-To: libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are just two users of _dl_dst_substitute: one is expand_dst that sets is_path argument to 0, another one is expand_dynamic_string_token. The latter function also has just two users: one is _dl_map_object that sets is_path argument to 0, another one is fillin_rpath that sets is_path argument to 1 and name argument contains no ':'. In any case (is_path && name[i] == ':') is always false and all code depending on it can be safely removed. * elf/dl-load.c (_dl_dst_substitute): Remove checks that is_path is set and name contains ':', and all code depending on these checks. --- ChangeLog | 5 +++++ elf/dl-load.c | 21 +-------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 2964464..a60277d 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -291,13 +291,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, /* We cannot use this path element, the value of the replacement is unknown. */ wp = last_elem; - name += len; - while (*name != '\0' && (!is_path || *name != ':')) - ++name; - /* Also skip following colon if this is the first rpath - element, but keep an empty element at the end. */ - if (wp == result && is_path && *name == ':' && name[1] != '\0') - ++name; + break; } else /* No DST we recognize. */ @@ -306,19 +300,6 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, else { *wp++ = *name++; - if (is_path && *name == ':') - { - /* In SUID/SGID programs, after $ORIGIN expansion the - normalized path must be rooted in one of the trusted - directories. */ - if (__glibc_unlikely (check_for_trusted) - && !is_trusted_path_normalize (last_elem, wp - last_elem)) - wp = last_elem; - else - last_elem = wp; - - check_for_trusted = false; - } } } while (*name != '\0');