From patchwork Tue Apr 30 19:25:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 793356 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp432583wrf; Tue, 30 Apr 2024 12:27:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbcE79KXJZsa3lrn24mWWpOqnYi0ATP2o3povadxBL6qUYLTb4o3Cfrw9bIDMhljFWQ/PAS6rOIvgGrwnAMCTD X-Google-Smtp-Source: AGHT+IGB60u8SmFhSdt0TvBIE/QHQyrxagCs+GIK0OUyN1W7N8O7zxogHKW0g+z4VYIiQZ3vjF/i X-Received: by 2002:a05:6122:3698:b0:4de:daa8:b8e2 with SMTP id ec24-20020a056122369800b004dedaa8b8e2mr727580vkb.3.1714505275987; Tue, 30 Apr 2024 12:27:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714505275; cv=pass; d=google.com; s=arc-20160816; b=Yg/t/Soanq957nmY+PQSy9H1rqdTigex8dCR2kgVPPFeOo98u5ImnKf4NZWkHQtrnO 7Ls+65tutSgFh8hcRpzJyDKi14wXnV5vL01YCKVO5fq2Yz1UKS46a037pamuIusx5/XK 7j1JGdQKykyozI+R1H6HPMH8DCTyLa17KYgaa142T0IVY+ryipKPiKqlymCh/b1F13z/ 1D4w7kCcCm/4MK/YJFwCuEOctI2ACNS0LlCYdoidxlUbjn0HFaNEeBFLM4j4KhWNlmX9 ZmRPjqPGV66boE2If4G1spfcyzK9MHs1/3UxX+8igUGF+ArEWhLkelX+Jc/szPvXmVJK iPTg== 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:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=29chawrxaKl5gCKvHbpQeohTLUCNG+48KWoVIEatP4k=; fh=Fj4D3X8lmeg8caKyS1psvSc6iiuGGH95h/ZziX55t10=; b=qKOrkt53XgDJxK5o/yZVVjhmB6F37Bqc0HMDoNvbUi2LaGl948i/XY5xzOUS4TCEZk rvRMcbinjhbkf2ItwHvjqyvHu9wYA2rbe6cBPIU49AGaDUNrPC4niS1pYlTVXiZt2Evi l0UMPmqeBOHQ2PVFwANipSORCvWY2nP5DfTzuxIHLBZ9cFXLSjUQAt13l/mEiSyPdKb6 Go4Gb9Ce2PcuaZiAxi6wjjOT7911T/yf7Pk9E0wrEgOFK3MohGfIfSwwe/cjB6WZPetx L4KR6L+AjRoswWlJfr3k68Nv0P1Yt1mKRsg9fDXVZCFJ69NY1wuN8l5qSjS+QM68HnNn 00UQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fao0kMTo; 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 a12-20020a05620a02ec00b0079065e4fbdbsi23201785qko.200.2024.04.30.12.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 12:27:55 -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=Fao0kMTo; 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 9CA833858C5F for ; Tue, 30 Apr 2024 19:27:55 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 2DCF03858D20 for ; Tue, 30 Apr 2024 19:27:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2DCF03858D20 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 2DCF03858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714505266; cv=none; b=pE+BNxkwZDdfR8xORsxHnllDURtWCatRLrRpi1neGhSN5Y0EIxRzUAdtwLnxjoZ3DNOzktR8M45KJ4jgBVDpzlWXV81RuZihbGbrTA7/pIfjysVFh67kE5Ac1ILM5USK5v/iLvMiKr6eaWZKIgt8Z6iAPzi2AjraEmbOvVy02VE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714505266; c=relaxed/simple; bh=6ev3pHMCworA8WSKYytho1iXjmBf5kPjqv0PQNQltxA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xwvaKTYAZ8rZpp2AfENT6KSNY6C65cGM/Vr+8+0ORRLWDt0aUZ6lh48PQFNn7vLW7za65z1BdkxY2m34RyLHbR5ccJKU8/RfUGJnhquH6sP0i5tQuMz3NWhcFtvo+1+Pl0Stu/wVjjeYHQx1KN3POYnICVPwT9B7FzKESPQPpdo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6f4081574d6so2233220b3a.2 for ; Tue, 30 Apr 2024 12:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714505263; x=1715110063; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=29chawrxaKl5gCKvHbpQeohTLUCNG+48KWoVIEatP4k=; b=Fao0kMToMUzoPOAvRW/G9o1HhMpMObykJJZm5noFv80oIxM6JAAnwYk5OPR7KKgqlf jJVG5dTf9I8UAC8BLeLlLg8GJogWJ55/H3aQ2/txREeIm3xcwRbFpBhWfqjI3k7f+5d2 m2oIR5FpEB10WVh4DFkjBk5jVL5MJwz+3JryvspTNOI4BVnEo2KXON2uIU9UDnwVXnxN PDS0mLZVCmZJEBE6vYXzpSdrlF/fAZAmmRGOpwqZppjup/LFJxvEBhiiYHIieouwHC/8 53u51AmhFuMWhCHgGA9NMAVZcL3+Z37JV1GDKG06rP9qc1BMaIrd7jUij0+DUnVvPf75 uQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714505263; x=1715110063; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=29chawrxaKl5gCKvHbpQeohTLUCNG+48KWoVIEatP4k=; b=ielP8ObgEb5ZJNnFkznJc/7P3N5Z7KoNR4ZsFtovSTJWXlUM/1iKy23nVpKACZ6Hjz WMii9gVTZKLq9nucAuyBCRWzhCJpcw6LkTuZI/3tw58NLoNLiYFQtORfWFfHWItTw8m3 O2P2cb9geiGGV9mkFBjOItDbarpmvNpN1g7BcJY5OM60jF3tkrvnQQOnDJgaEO9AWH1P A3xdnvEAkdHaAhtqpWS2XtqkObc5r5oE1GG3mpilyxB5kqyEnH5fqQqY3uqNf3vSJ2H6 lLoCmc79cdlaWTDpYhhdSYVCW7G3p7z8q/yOyt+L+2p7UsR4BfWROHHd+ZM35iX1j1XD UKSg== X-Gm-Message-State: AOJu0YwnNI9g9JFIHebVltsLtW4+1oP7PUcbi/9qSZ0is8SSi92dCk7i RxyMJtAUCXBkAp2T3QPqRAtAVqk6P/G1GXZueyRD6u/rYHZnIBzvrqtXLaY6fkkYn+tv8ZatfcW y X-Received: by 2002:a05:6a00:842:b0:6f3:f062:c09b with SMTP id q2-20020a056a00084200b006f3f062c09bmr668719pfk.6.1714505263502; Tue, 30 Apr 2024 12:27:43 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:e3c5:c9b5:f382:64ea:c32b]) by smtp.gmail.com with ESMTPSA id gr6-20020a056a004d0600b006ed1ea5219csm21449143pfb.130.2024.04.30.12.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 12:27:43 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott , Siddhesh Poyarekar Subject: [PATCH 0/4] More tunable fixes Date: Tue, 30 Apr 2024 16:25:01 -0300 Message-ID: <20240430192739.1032549-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 The 680c597e9c3 commit made loader reject ill-formatted strings by first tracking all set tunables and then applying them. However, it does not take into consideration if the same tunable is set multiple times, where parse_tunables_string appends the found tunable without checking if it was already in the list. It leads to a stack-based buffer overflow if the tunable is specified more than the total number of tunables (BZ 31686). While fixing this issue, I noted that the new glibc.rtld.enable_secure check could be optimized a bit to avoid the string comparison on the tunable loop. I also found an issue where it does have the handle case where the environment alias is handled before the GLIBC_TUNABLES, which will change the tunable even if glibc.rtld.enable_secureĀ it set to 0. Fixing it allows us to optimize the environment alias parsing a bit, since only tunable with aliases need to be checked (instead of the whole list). Adhemerval Zanella (4): elf: Only process multiple tunable once (BZ 31686) elf: Remove glibc.rtld.enable_secure check from parse_tunables_string support: Add envp argument to support_capture_subprogram elf: Make glibc.rtld.enable_secure ignore alias environment variables elf/dl-tunables.c | 112 ++++++++++++------ elf/tst-audit18.c | 2 +- elf/tst-audit19b.c | 2 +- elf/tst-audit22.c | 2 +- elf/tst-audit23.c | 2 +- elf/tst-audit25a.c | 4 +- elf/tst-audit25b.c | 4 +- elf/tst-glibc-hwcaps-2-cache.c | 2 +- elf/tst-rtld-run-static.c | 4 +- elf/tst-tunables-enable_secure.c | 131 ++++++++++++++++++--- elf/tst-tunables.c | 61 +++++++++- scripts/gen-tunables.awk | 64 +++++++--- support/capture_subprocess.h | 9 +- support/subprocess.h | 7 +- support/support_capture_subprocess.c | 5 +- support/support_subprocess.c | 5 +- support/tst-support_capture_subprocess.c | 2 +- sysdeps/aarch64/multiarch/memset_generic.S | 4 + sysdeps/sparc/sparc64/rtld-memset.c | 3 + sysdeps/x86/tst-hwcap-tunables.c | 2 +- 20 files changed, 333 insertions(+), 94 deletions(-)