From patchwork Tue Oct 10 18:01:04 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: 731463 Delivered-To: patch@linaro.org Received: by 2002:ab3:7922:0:b0:23f:8cfb:5ad7 with SMTP id j2csp2263167ltl; Tue, 10 Oct 2023 11:02:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7RUmpTFdmapUTp8Wq8pKN7l5k50Md2Wxz9yPXuCxdBBBui5m3AA37BVPl6OCdGo9CvByh X-Received: by 2002:a17:907:2724:b0:9b2:8c37:82a with SMTP id d4-20020a170907272400b009b28c37082amr15887933ejl.35.1696960944358; Tue, 10 Oct 2023 11:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696960944; cv=none; d=google.com; s=arc-20160816; b=ZxGO7demvhTo+qciS5I9D4bF9Lkr3j/irKRtTfp+zF3UInnUJlRA0QofZSdYlCmLHw 9WSCiTew+Zcrd8ZTcU5VF1Swwasy8UoUrUCLyH2jCdPa7w+h5BdP/Xrid3TEpFU7jDMi QmQqnMIVJTzS6/15SC3RfX/dcEuxYoUceMavIXxA4xl1nNM71WiHBXHdVpLikkbzCzsP KsNIV5Sq7gfqKcId9AN8rCNXK4Ff+v0CvQLgm0RhDg13C3R+UtQbyXLrUqr5pbSTEwjE 1v9qdfeHx1kBwYqnKEko1Qnilr3UQ+4DfxfQeZPj73xpUhwNhIOTMGpur7zVZ9qrGKSe 1ujQ== ARC-Message-Signature: i=1; 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:dmarc-filter:delivered-to; bh=eSuMA4mgrZt7SdXvzgS9MfY7s68dpBZNh9Rn0TMYRHs=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=iXX7Vtcr/NVwSkg6FgTlQbOIk4liO4CA/o9shI+jp+GC/QwpRz5hwdCVwEQjSsfZHw LKp+ogYjRgXk5y99c5XEiEdpdpbT8txSU9tY+DaJSuRi8TtJH4URn4Xl/ZXbdZjiIgDs qFte7WHxP1BNCatmJtNxdjgpX4PxVXOWituSk0BQXHalaTbAnHQOY0+tT7DrIkmFjfbx 9Q6obKyPPXVZMfKJHvzWXyjZn50SY2DzrZt7X0+i+a0zqI521YbCqVhEJCRkhjE4ctRb pDlXSFwYgOaFMHiUvFPfNtVzDGvbuqKgih/fLZVRkTrS14+bypQKfzbP2jre+yiKRnQ1 gVng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYTpfEKg; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l11-20020a1709061c4b00b009b2c2ae87f1si5695559ejg.573.2023.10.10.11.02.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:02:24 -0700 (PDT) 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=BYTpfEKg; 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 0902638323D5 for ; Tue, 10 Oct 2023 18:02:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 26FAF38560AA for ; Tue, 10 Oct 2023 18:01:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26FAF38560AA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c723f1c80fso38357475ad.1 for ; Tue, 10 Oct 2023 11:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696960886; x=1697565686; 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=eSuMA4mgrZt7SdXvzgS9MfY7s68dpBZNh9Rn0TMYRHs=; b=BYTpfEKgdsOiZBXF19bapVrKmyDwy/rDQVapxTMDYeZj4cH/6Fg0XWeYTFi1LLmwn5 GxEcv76I4YJqREY1K3cLlFuoTALex7NvwhlUeiyOa7gZ9SeymP2Do28YCyybOd3uBmEq Hp8hhWEViAq5ZjoOlKki/Hp+SKSo+TAJqm7TQ/NrkD/IQoSf10axnDEJhFb73owYkFpK A9E6QTLQjhfyRz23MKu1NI2GhoFc9lWnRCfe5L63KwCAtef+u02bVDL1o/e3ewDOZtPc lr+8pKP6ogt0t8ZOPiq323Eyx+Y8QvE7lmq1DcaU4RkephkIHtcSaVDDlNXnAyiWYTCR nw1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696960886; x=1697565686; 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=eSuMA4mgrZt7SdXvzgS9MfY7s68dpBZNh9Rn0TMYRHs=; b=aR3AMdLHOY2Gc4YWmbIwnMtB6l0eUvWbhnex8QALv/RmO9KmbGN5xjDKn5PML0eHtf 0fb3eBS6+Jv8f5k7w3ZWjjGQqCRHOxke8qJi9bF1SoXTDyJGiaEQ+NhfFih7g+4eQtxW qCHq4kZB1pEM/0T5V1tg1zM/DssD4vxMMdl3IH45XQ7l6QP3HudtRljLJP0A2FYT8lAJ 1DHjpAqxBz+y1GFmmg8+EuYRzcCD6Q+09JIghtA9/Jl1tyIesp+UJXEq92jC37+AjRZW wbC/bT1bM9xx6ZmVBcxminNEHfH8WcDFuRm2IgccNvYQ6ezWlmyDLkIiY/4Rs2ZkSr6E DlEw== X-Gm-Message-State: AOJu0Yx1tt+m1yWvnqZFbWjxUtREvzysv20rfqmqWUqyzrlrDgFfVkz/ jx34CdBWbTpWZKGzAHCoKMzsbHUUy/0VyMW0Wl70Lg== X-Received: by 2002:a17:902:ea82:b0:1c9:c733:67c1 with SMTP id x2-20020a170902ea8200b001c9c73367c1mr710898plb.14.1696960886477; Tue, 10 Oct 2023 11:01:26 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:d09b:ef2e:7c42:5ecf:a4ef]) by smtp.gmail.com with ESMTPSA id 5-20020a170902c24500b001bb9d6b1baasm12088022plg.198.2023.10.10.11.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:01:25 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH 04/11] elf: Add GLIBC_TUNABLES to unsecvars Date: Tue, 10 Oct 2023 15:01:04 -0300 Message-Id: <20231010180111.561793-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010180111.561793-1-adhemerval.zanella@linaro.org> References: <20231010180111.561793-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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 setuid/setgid process now ignores any glibc tunables, and filters out all environment variables that might changes its behavior. This patch also adds GLIBC_TUNABLES, so any spawned process by setuid/setgid processes should set tunable explicitly. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer --- elf/tst-env-setuid-tunables.c | 11 +++-------- sysdeps/generic/unsecvars.h | 1 + 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c index 3232f6b4c1..39b3648aa6 100644 --- a/elf/tst-env-setuid-tunables.c +++ b/elf/tst-env-setuid-tunables.c @@ -64,15 +64,10 @@ test_child (int off) printf (" [%d] GLIBC_TUNABLES is %s\n", off, val); fflush (stdout); - if (val == NULL) - printf (" [%d] GLIBC_TUNABLES environment variable absent\n", off); + if (val != NULL) + printf (" [%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val); else - { - if (strcmp (val, teststrings[off]) != 0) - printf (" [%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val); - else - ret = 0; - } + ret = 0; fflush (stdout); int32_t check = TUNABLE_GET_FULL (glibc, malloc, check, int32_t, NULL); diff --git a/sysdeps/generic/unsecvars.h b/sysdeps/generic/unsecvars.h index ca70e2e989..f7ebed60e5 100644 --- a/sysdeps/generic/unsecvars.h +++ b/sysdeps/generic/unsecvars.h @@ -4,6 +4,7 @@ #define UNSECURE_ENVVARS \ "GCONV_PATH\0" \ "GETCONF_DIR\0" \ + "GLIBC_TUNABLES\0" \ "HOSTALIASES\0" \ "LD_AUDIT\0" \ "LD_DEBUG\0" \