From patchwork Tue Oct 17 13:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 734391 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp469410wro; Tue, 17 Oct 2023 06:08:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAEEUdKLUTV0XqlBCkbzdfzw9RD5qWV4q2Tdwy64+sxNNaH3NfzbE8QKAO+4hHEGS6VuOz X-Received: by 2002:a05:6102:298f:b0:457:c2e1:64c5 with SMTP id dl15-20020a056102298f00b00457c2e164c5mr886941vsb.7.1697548084884; Tue, 17 Oct 2023 06:08:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697548084; cv=pass; d=google.com; s=arc-20160816; b=OUWusSPE/15ahYhdMmdcmNoGcN+gCIDqRiBIhLsOu9vW0/6aoLhkGqyU+UHF5mPx2X ceuyP1OMB2JOQk6hjNIiYSHI6dxMb3sb9fuKLkwTGTD5WLU7Hywk8QSt+A+rlBzXuNcF YM+RJsXRbsA3qepfCr0vHw9EVY3EQbsNAz6GWEek6/N7CCCYr2P9rlcCl/gDanceiht6 gshgEbuQCbSd5fVdF5+fAnkPAMXi4lw031Vkf8DBlaQrQBQ0tIocRw34e1SsrV1KrLrd tIiJ7Mf3ktRLGkdceDupuCDUmwHjzHenKWtbmceHQ7XpEx4GbTmF9oJN8vDU7zP5xZEW ERsg== 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=FPDBnoEkGIJKJvl7qQEntr9JeOl2clDFFXATUG1ArG4=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=Mves4YWBcxLsg4bMQlV9msKD6ptkhBV60IUmY1DMRHmZbjHlojghHEeX9/kiwu5Fc+ jkbifM9Mhlp1DuCZbxGLH0od6ofEhVn5xeqpMCl6Vt2xbyPZykuHPVupfFqbkmJd7NDF dL6zFHNgw7r8dN4eXFumVOfHQmEIJQfqyWz7tUq4vvWfUu7ImBsvGUk8Vzr4Pqw6xDU1 1ArzfgisOKI5kL9W+qKIR3OfGhhm0VIrNUWiyTuQDEEV5nFPfVtrYAw7S+kiFEN1MOzm Pb381uNKVYxGyNrpSbKVWf/mIpC6DbUB3X8QEcLwubbITpqstd2yPvMa0I4fdGpHEjwf 21gQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BQoQ1xIx; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w18-20020a67e252000000b0044d48897e9esi107037vse.142.2023.10.17.06.08.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BQoQ1xIx; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 D4F88386C5AC for ; Tue, 17 Oct 2023 13:07:46 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 468F9385F00A for ; Tue, 17 Oct 2023 13:06:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 468F9385F00A 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 468F9385F00A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697548004; cv=none; b=NnWFV9enzbW9iMt28h96R/H56HeS7+rhJd2gXVSad/fLy9kHBdkBwaa503ZPbCRoOJQLdKmhhnEZ8KpMKSda/VRl+pTs+Le23KTSt9x2nG8GDhu46foW4mrolh4wg/EZDIlNRSk2TWW9ck1EkHwFFpxoSLRVKnop4fkesgtDTW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697548004; c=relaxed/simple; bh=A/pECWmltQu5nimLsDKwaWDtWTaGzJMpjI2k8M0G+Jc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=VpxzKxFF3wdk0LDSQxYmAaG2AqK1Bg2AkUvyxwnoqboowzUCOufUgGwQOzA/TxY+WgERECXw8k+UesSrPUmeO8n02T3Wgw/7BQ4lLttrcI8Cd8+9KzZK5rgCRa1nU4CXChOhe6pWqhDWjWmkLvE6w2EQtkKJyGQR5kP5/1F+it0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-692d2e8c003so5095006b3a.1 for ; Tue, 17 Oct 2023 06:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697548002; x=1698152802; 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=FPDBnoEkGIJKJvl7qQEntr9JeOl2clDFFXATUG1ArG4=; b=BQoQ1xIxOKpoOp/UA4ez2YInLQBGUM5Vf/U/XabcUy4BUpVLnpSDIdMNWoC4eJJtWb C/gGOVdKxrXVvgjK3gnB6GKcP3p4NXwy7I40dsD/u0W4J5/iQxQLUDgh4Lwn29Q2ut5r GeQWH6Uohy0JvVy3B7cpcqPc/2opIjOE7nMjh/lPH3sZQi7bXJzgyON2qhW2fAJ1z4iL hdDxxleGNJ3HHjYEIBwdNGX7G+9fhSU795PRL5SWv8WfdA5eBWhGEZxJCbXEQBdAXk1R JSGzirqUJTv9cNsxqIhKGzpujZfiT1TMIeLaXMCd6wjydxdXyEkHaQBbxEiKVFc+ZNY+ wgTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697548002; x=1698152802; 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=FPDBnoEkGIJKJvl7qQEntr9JeOl2clDFFXATUG1ArG4=; b=vrkJk6WtDeo75vFskyGoisvHfciC4DbXWQMhePadEcEGYmqK38pW21NpOue2vMR9xT whMOAUHcGh1PMJAali9JU2Nkd023Ra8l/aTYcNj/KKLMjKeRZ+z6z1xrRSCuCHDxs9jk dsNK/zBTj/1w0ai8lXy+CwonzYxraZE7aFvggxAk9PDWFPrko4uiiQw8mx1Os9QTrGet WkWbrV5Q+j+OU7w4daRMRWZbPBq0LwfX6G593jHdoIq6klylsnPz0Q6iEOrdtCoO1UXD R2ndlSRLxHr8b7NmpzToowDrgN3YeN/Ub84Ry9jqexaut0UL9j/ARc15lhNMBrttmpsC yoqA== X-Gm-Message-State: AOJu0YxQknU3ZTvJ1o/Y+wDnjNXpqrH5+ktAkXW1Kjenh5kChGcuCWmR xzUTF0JzcacP7tYzlkVIFlo8lzUEIOdT+pe4V0t2Jw== X-Received: by 2002:a05:6a20:4413:b0:17a:f4b6:bf89 with SMTP id ce19-20020a056a20441300b0017af4b6bf89mr2164297pzb.31.1697548001835; Tue, 17 Oct 2023 06:06:41 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:7f2e:11d:92b4:4d78:4197]) by smtp.gmail.com with ESMTPSA id l28-20020a635b5c000000b0056b6d1ac949sm1309788pgm.13.2023.10.17.06.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:06:40 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v2 14/19] elf: Ignore loader debug env vars for setuid Date: Tue, 17 Oct 2023 10:05:21 -0300 Message-Id: <20231017130526.2216827-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017130526.2216827-1-adhemerval.zanella@linaro.org> References: <20231017130526.2216827-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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 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..8749ad6288 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[] =