From patchwork Mon Nov 6 20:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 741463 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1294738wrr; Mon, 6 Nov 2023 12:27:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHy4OdjrMWslCfZAjJ3wAVH+GBCdIFjneS5gr3e72CaJgx1iln4evQRZfy8KZ4ZMobPH4++ X-Received: by 2002:a05:620a:4147:b0:773:ac84:3f57 with SMTP id k7-20020a05620a414700b00773ac843f57mr875594qko.5.1699302450304; Mon, 06 Nov 2023 12:27:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699302450; cv=pass; d=google.com; s=arc-20160816; b=V2RwdSbV0qFiZAaxASNzEqNpXcJ6MfcVceTr2BGFOsy9G5TWIDjbNbpxZ+TPIHvxyo F3BfSG3NBqY56GrUT2JvmpQOVouD2P+C1X4FucyNaCXs3puOFSf9vZ9GdVhn1nLOZqk3 vIbr2j4jmDm6cQUpDoboLf1BhMQnGG5JcCYl++Syw+tah3RC4S2uIfPThr0ouxtmlc5r XgWEv3O2vOzFtwregdSyjIg09K5+5V2RPX5DuM5mojyF36viS7phS//UfGcwB8btA2jc WjXa5w9lOksZtfQw46PEBAwkW9FNlJXpNsHSlIPUUXBQLqj+dP7gd6M1CKWAD/0Q0jmB HoCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=xbdIEkPXf1TNi8Tg65MBpgFZidSq0Zsnzkd7udROqYU=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=lrytbJ5EYuKS7ipHBr9i4YLLgqKO3bwQQmaxf393K+bCkWnHlfM/BNDUEOmvVLXekl nEx/l/X5P9k6yIqCQVWg4I0K+2KIjrREvUodWTnybNx8OaFhG+f1vHC9QbzgyvAbfwI0 +ZEYiSIaqCCBS2DcWmSpAOhedtdfG+F8gsn3zf7HkK80hohB3BfUlI+2Qgcha7DYyxCy JjKZ81R698SGES0yOlChKtp6o8GmzpTNqlMXRKSPMacTGqk3LP42ADQ8hPClW7Wuaq6o j8GcGKGxvj9Hoszv7ICD0US2D4zaFV5e4l5ZYXUGTfSdfjdLQ4g+c/ZUZv3i1UpWl/rc uKYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zXNy3wtW; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dw22-20020a05620a601600b00779d0a62e5fsi6456048qkb.660.2023.11.06.12.27.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:27:30 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zXNy3wtW; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 014B73856DD5 for ; Mon, 6 Nov 2023 20:27:30 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by sourceware.org (Postfix) with ESMTPS id 0BD9C385E00F for ; Mon, 6 Nov 2023 20:26:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BD9C385E00F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0BD9C385E00F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302392; cv=none; b=kjP97uV/eY7KUyYuZke2Zc2eUFdt0YRuzUe+wvhESG/PAPYGAbZS5RZv9WYdrf4pVU3V+PSdS7yvorylPvVxFaD8KoMBe24AlWz2aY97IndiDYdmzi17VWyX2hyG66PcjUSL+QXEIVhn4IckkQoDBGhjzKN5HC07vTVCDiIU+RM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302392; c=relaxed/simple; bh=uofAC9D0T1jSR+uvqfAqv9BjgFc4EZqt5R4L2OlqKe8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=o3L/eT1TFADqhPpfzgdscUH9APpthQIQFA6t24uemlp7f4Ng0qonubmBIdJlzIBZB5Vl8VyY6EYcoGndR08nva7GYQT4mEot39qQA+M0aZ8IxK73oXBzJY+Zy6g3Tv2PEBBdqSCNljhgeOpo/NnwRzFyfGx4ed3nj6c3xcFF2DA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-59e88a28b98so42836577b3.1 for ; Mon, 06 Nov 2023 12:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699302390; x=1699907190; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xbdIEkPXf1TNi8Tg65MBpgFZidSq0Zsnzkd7udROqYU=; b=zXNy3wtW6SBFcSAvR3etIHFhH12oMJXsqK2NFCtyQvcIz9jpLLU8d97Tz0SMjXPtVb JnLZvqsgkOzVqKPa/JwmfBSBbeQCh91w9sEws2byGbTqAzKUt9rG5OOemTjjMcoCuN+W KeLznb0ip2Kw57/dtuOam46dZdcFATKOIoDnbw5T5sc7+VOi1DIJWnIdqDVWEkCpPjOf Jew30Y9aFpw1BWJJoetQ8bXlooZqLHequ8i2nin/qcq5aMavqJ4/w52so+IXj2mm33H8 9H8NjqeowuuINsIgx2yGvcTWelBjYFfmDU2mWdbkCFmxzURnMSwKdA86Pa2HYJFfrB+T YgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699302390; x=1699907190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xbdIEkPXf1TNi8Tg65MBpgFZidSq0Zsnzkd7udROqYU=; b=JgOk9FLLES4sDXxZPIAhgDrN4Ny1ySJJEIWl1Wd/tgQ+mb5gTdW8rYRKpeXHGV70FJ RudYxA+7Ad1CkKhiPQyMPK7/6E6XPNtnmO1nZSPtQeXzruKdiBtUT/VZO96kv5U5/pW1 riN4ySft2ctuFt7TZgZgUUvdXYNh/k3fPaJqJ17zE4EVQlHOR2DXpI5wlLmuNqYTXz54 w9Se1ZjLusjZD8xOrsmhKTwpxzZLBxOZUTiGz0j9RdV8UELz1cIB/AnJqQ1X29b/ZHIO 2Ol1c30KsBFGtxLn12kBEiX754Kmo8z1cYnx/oUy5CM8lN/jYFOjaK9dWIxUi4sQkYc9 yOQw== X-Gm-Message-State: AOJu0Yw9qM2fQLhFhGyQQPTdv9ZBB9UZaLgG4f4vP4LROGsTtupomf0h WkxD8e8oW/dTUYv3gH11SntQspFLNRjhzVfgizXyoA== X-Received: by 2002:a81:4c52:0:b0:5a7:f61f:7000 with SMTP id z79-20020a814c52000000b005a7f61f7000mr478526ywa.1.1699302389989; Mon, 06 Nov 2023 12:26:29 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a715:c1a0:7281:6384:2ee9]) by smtp.gmail.com with ESMTPSA id ci7-20020a05690c0a8700b005a7b8fddfedsm4707154ywb.41.2023.11.06.12.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:26:29 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v3 16/19] elf: Ignore LD_LIBRARY_PATH and debug env var for setuid for static Date: Mon, 6 Nov 2023 17:25:49 -0300 Message-Id: <20231106202552.3404059-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106202552.3404059-1-adhemerval.zanella@linaro.org> References: <20231106202552.3404059-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It mimics the ld.so behavior. Checked on x86_64-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- elf/dl-support.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/elf/dl-support.c b/elf/dl-support.c index 31a608df87..837fa1c836 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -272,8 +272,6 @@ _dl_non_dynamic_init (void) _dl_main_map.l_phdr = GL(dl_phdr); _dl_main_map.l_phnum = GL(dl_phnum); - _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1; - /* Set up the data structures for the system-supplied DSO early, so they can influence _dl_init_paths. */ setup_vdso (NULL, NULL); @@ -281,6 +279,22 @@ _dl_non_dynamic_init (void) /* With vDSO setup we can initialize the function pointers. */ setup_vdso_pointers (); + if (__libc_enable_secure) + { + static const char unsecure_envvars[] = + UNSECURE_ENVVARS + ; + const char *cp = unsecure_envvars; + + while (cp < unsecure_envvars + sizeof (unsecure_envvars)) + { + __unsetenv (cp); + cp = strchr (cp, '\0') + 1; + } + } + + _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1; + /* Initialize the data structures for the search paths for shared objects. */ _dl_init_paths (getenv ("LD_LIBRARY_PATH"), "LD_LIBRARY_PATH", @@ -297,20 +311,6 @@ _dl_non_dynamic_init (void) _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0'; - if (__libc_enable_secure) - { - static const char unsecure_envvars[] = - UNSECURE_ENVVARS - ; - const char *cp = unsecure_envvars; - - while (cp < unsecure_envvars + sizeof (unsecure_envvars)) - { - __unsetenv (cp); - cp = strchr (cp, '\0') + 1; - } - } - #ifdef DL_PLATFORM_INIT DL_PLATFORM_INIT; #endif