From patchwork Mon Nov 6 20:25:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 741461 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1294690wrr; Mon, 6 Nov 2023 12:27:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEX5YHdnc2LTPCYnQ1bxk7lXpL9CJ7qsSYyEolOurcQPKNfxr912S128N/Y2AFk7+3o9DeE X-Received: by 2002:a67:e01c:0:b0:45d:9017:bc4a with SMTP id c28-20020a67e01c000000b0045d9017bc4amr6240722vsl.6.1699302438686; Mon, 06 Nov 2023 12:27:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699302438; cv=pass; d=google.com; s=arc-20160816; b=FbgjHOWOFIIZBuxrnP/BHTh2VdE179ndGM8DeEktGztcYoIZBFxrVdF+4AGJiwQybv zlc2d46qIPbGHoYzfU1/m2//hjuvASKC+fUDk8fdO9t9raJb1RjxXzZ4Rtj72NLLpJ1E pom4bAgWF66lRbFvsob7TiVFjUCdn/CB+8Vt8c+dOPYCxTyfpuHJGjZNsUjSiP8QPKqX vHGe3+tx2E95ZDTvFBFRWNrC3F9bwWMeeuYjQ6x7ajmcWyVBUrEOH415tsqyftIqdbW1 Jz/CczMBh2UyPpkvmI2ZsVOrMhNJYYLyp360OsgEgAe5+24k4LzwldB/2m0OeJ9TYtGn FQeA== 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=jluY1futqbV0kiB9ZnYNIOlqaz6IeM4BOuQX6u9hb/M=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=VOri7I4A7nxB50m9qep10aleo6AxVDnLmvk0oGp4a/iTCf5U6lYQV1aIms03t/Q79F /I3/EH/DWj/wMgWA1lmgRtHVKrprrTcx2LvaBwukX++4MduGV3waUgMdyeC+RGUo8hLb yoAkrIu2bNOxMXzItHgV3HEhjj0wNFEffnjDLosnBK7Sweao04V1T0+CcwLEDll6a5BS fCKkfPmPCiryBzC3MILo97o1WAsgphrzKOKuHHgESvZkvPB98yyWAfm0j0N/xS2RCaOm zJPlaBOsNAfK6LpfRDvEy8b8Th9PHdoaBFWJb3a1R2fezXg+CN0vDk2hL+LWQGA7kdW2 3isg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fbw8HK8V; 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 y1-20020ad445a1000000b0065b240236c1si5986596qvu.403.2023.11.06.12.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:27:18 -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=Fbw8HK8V; 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 E39BF385E007 for ; Mon, 6 Nov 2023 20:27:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by sourceware.org (Postfix) with ESMTPS id 5A0523858C30 for ; Mon, 6 Nov 2023 20:26:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A0523858C30 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 5A0523858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302389; cv=none; b=gjTEtTSaSeuy/RHbtTGLHQDpgXh8UlbIG4u1NPqsKkhwVIKP1PtO93rpget8WuiLCaPhK/+etOpfAod1nCVEmWDEaFFVr/K29/3D9YDBzQX+C+hkPs+vT13jEME0fpH9rLQXZ4mIVHNPb2R3vJjoknBJVaHKFOpNbKKPlDjbMkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302389; c=relaxed/simple; bh=S+KcCnjq4rLBN3SyuYNbx6m/PF7OSvT2JnHhXIKnk6I=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Zy+ROa/GcP4HtBXayOUlejJtbrq7OoYp24M2pBHrknjkjm0WuQd5DWjW8iNmyMczk4H6a9T7DGuYoxHHqm6pKLH0UMjFnoMDkRylCbxHbsaJsAhRCT/U18N4NuhxTm3oDH2BX+zL5A6KO0p56ca+K4X5w2Xkp2w54fE8yzYlLSw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5a822f96aedso59176847b3.2 for ; Mon, 06 Nov 2023 12:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699302386; x=1699907186; 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=jluY1futqbV0kiB9ZnYNIOlqaz6IeM4BOuQX6u9hb/M=; b=Fbw8HK8VVY3NDaM4v5zW27mu4G0eUZrIv5jx0aw5bQd8Oxr5y1DU1GktEttdsEAcIv S9DJezsiGo4K6Wlcjo1bKiXD4cTu1/AA0RzvKM33ioUs5hv+hgYpt4010Wlx4QSC84L7 faqH8mKKJyj36JMb4drWqsrx1YLCzlSjDYuYg3SmxXW0iqdppKpxDl0/Nnz0hokou4wL M7pLxWn3CtF/JNl6DPxWFQ5suwAKt7Vg8gHjF5t9zBaZdHKI/eLK0Grgqln8kOZ5xdF/ 6NxnAYvJWVi1HhKY0NHQY51GQQHGWxsrr7DCpKcUgwAhg+kQq/8gcvf4SyShuARZw6BS LGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699302386; x=1699907186; 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=jluY1futqbV0kiB9ZnYNIOlqaz6IeM4BOuQX6u9hb/M=; b=nJZDpeAkhLTgQa985QNnGCJEU11vOx1dFdQ/RIMhC4m6lcMXTLokZrUXlBv4vLjppp VAiyv6TB06pNfTqHLoCMprrkdUtXwEhAFxBmBBiDbSeN7LVEpuc9HaiL0+wpRX73NzFs ZRRY6gRd4DMYVHfr/16MR3gf50qR23fwy3ogRLIbAbeeacZ5e0IiVKQNAlpCCxBvzOUT 8EsNsQRo3s4AxwM336OBl5mh1JfhCfzBRZcV44k54I2YYehIBTjvNKw+2TFAUxImQYqs SD3KfJcL59HBjEzqLn1WS5TZuDh1/ibVKrT288zxzX0McfkYqS0wPiJrWkEDCYNnPhqW QQtA== X-Gm-Message-State: AOJu0YylpoGXiwd4JkQMLbvMomXWkwGY+Jx14hdoq4aSwWFIe7HqgZ+L KJ+IiQjdIs4qm3RLmgX2sF5twZSoVMxFXglgBp0X2w== X-Received: by 2002:a05:690c:fc8:b0:5a7:bbd1:ec21 with SMTP id dg8-20020a05690c0fc800b005a7bbd1ec21mr13657526ywb.0.1699302386331; Mon, 06 Nov 2023 12:26:26 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:26:24 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v3 14/19] elf: Ignore loader debug env vars for setuid Date: Mon, 6 Nov 2023 17:25:47 -0300 Message-Id: <20231106202552.3404059-15-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 Loader already ignores LD_DEBUG, LD_DEBUG_OUTPUT, and LD_TRACE_LOADED_OBJECTS. Both LD_WARN and LD_VERBOSE are similar to LD_DEBUG, in the sense they enable additional checks and debug information, so it makes sense to disable them. Checked on x86_64-linux-gnu. --- elf/rtld.c | 22 ++++++++++++++-------- elf/tst-env-setuid.c | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index a09cf2a9df..e7f90d37e7 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2552,13 +2552,15 @@ process_envvars (struct dl_main_state *state) { case 4: /* Warning level, verbose or not. */ - if (memcmp (envline, "WARN", 4) == 0) + if (!__libc_enable_secure + && memcmp (envline, "WARN", 4) == 0) GLRO(dl_verbose) = envline[5] != '\0'; break; case 5: /* Debugging of the dynamic linker? */ - if (memcmp (envline, "DEBUG", 5) == 0) + if (!__libc_enable_secure + && memcmp (envline, "DEBUG", 5) == 0) { process_dl_debug (state, &envline[6]); break; @@ -2569,7 +2571,8 @@ process_envvars (struct dl_main_state *state) case 7: /* Print information about versions. */ - if (memcmp (envline, "VERBOSE", 7) == 0) + if (!__libc_enable_secure + && memcmp (envline, "VERBOSE", 7) == 0) { state->version_info = envline[8] != '\0'; break; @@ -2625,7 +2628,8 @@ process_envvars (struct dl_main_state *state) } /* Where to place the profiling data file. */ - if (memcmp (envline, "DEBUG_OUTPUT", 12) == 0) + if (!__libc_enable_secure + && memcmp (envline, "DEBUG_OUTPUT", 12) == 0) { debug_output = &envline[13]; break; @@ -2646,7 +2650,8 @@ process_envvars (struct dl_main_state *state) case 20: /* The mode of the dynamic linker can be set. */ - if (memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0) + if (!__libc_enable_secure + && memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0) { state->mode = rtld_mode_trace; state->mode_trace_program @@ -2668,9 +2673,10 @@ process_envvars (struct dl_main_state *state) } while (*nextp != '\0'); - GLRO(dl_debug_mask) = 0; - - if (state->mode != rtld_mode_normal) + if (GLRO(dl_debug_mask) != 0 + || GLRO(dl_verbose) != 0 + || state->mode != rtld_mode_normal + || state->version_info) _exit (5); } /* If we have to run the dynamic linker in debugging mode and the diff --git a/elf/tst-env-setuid.c b/elf/tst-env-setuid.c index 76b8e1fb45..dcf213a4cd 100644 --- a/elf/tst-env-setuid.c +++ b/elf/tst-env-setuid.c @@ -59,6 +59,8 @@ static const struct envvar_t filtered_envvars[] = { "MALLOC_TRACE", FILTERED_VALUE }, { "MALLOC_TRIM_THRESHOLD_", FILTERED_VALUE }, { "RES_OPTIONS", FILTERED_VALUE }, + { "LD_DEBUG", "all" }, + { "LD_DEBUG_OUTPUT", "/tmp/some-file" }, }; static const struct envvar_t unfiltered_envvars[] =