From patchwork Wed Dec 6 13:24:00 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: 750725 Delivered-To: patch@linaro.org Received: by 2002:adf:9b9d:0:b0:333:3a04:f257 with SMTP id d29csp2241072wrc; Wed, 6 Dec 2023 05:24:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIe8fcYpnbIRjZSJWnSk0IcDzUEqmEl5NLv4pu1aDJQnXnxTYNiG7Wp97/770l6NWbyKzP X-Received: by 2002:a0c:eed4:0:b0:67a:a3c3:90b4 with SMTP id h20-20020a0ceed4000000b0067aa3c390b4mr819005qvs.36.1701869056017; Wed, 06 Dec 2023 05:24:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701869056; cv=pass; d=google.com; s=arc-20160816; b=YqTcLnBpQWm5f74Xwwq9fGlrYKzkAJWF0bPbKNWw74jhTk00FrWZvzavr5q6P55Zy0 b0dKk+nvqUmvqrw3RCeGa5RQCXUL0jKFTI9Z6NgVOSQT1yFQSzHUq+nVCHCnUizdNJ14 9UVQThBbcqy4D9OxqmkooI39iwhrXkDqPYIoqhfcLonViOuP3d5+yBsJudx7pp/e6glq +9Wr3oxxYRWLw9P37NUyb5uxx++LURxpdLoC9aM7qlgE+8FiMffqrAHaFzUUOGkafyMx X2hMovZV2O2j/0AV8C0X/Vgo2OPtkanhfLtr+OGo2qgX77bzu70eioOTACmSkR3gSgg0 hQjQ== 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:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Zg1VxcADULak8GnV90JoW55uWQbZN0gZ2F2U0HD8soU=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=uXAdObewGSSmHNiwV3lzRIgAHFL635gT2pInfL4nG+2e2RNCpsJDSZCpawq4oBlvc0 mzjlC7yfDkyPNOjsifkw+c0BcRV3N3v01S6JTYtuEMt9Pe8eLJAHLj/rDrripxjAXiC/ 2mPsaGkpnAQYIJWge5R9zlKqhmEpql+sxxis9CZMb/MucWAUvq51EL275QIROZUQfWUu dVt58d/8twSxEcVENhiNlXgSKZA/ihWyfiPkYJMDBiJSFy/JzZlLdhjPgoVygPaiyshx cDRt8tHoF4Ey5WiPggLuwP0B9vNu/a4h5ab+OF1YFgb/nCN4wUt0aiOos6vuAn8KfLC7 j+Eg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Uu0g/cmY"; 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 fn5-20020ad45d65000000b0067aa63bd67fsi11141210qvb.513.2023.12.06.05.24.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:24:15 -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="Uu0g/cmY"; 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 A3D523858C54 for ; Wed, 6 Dec 2023 13:24:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 2C8DE3858C54 for ; Wed, 6 Dec 2023 13:24:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C8DE3858C54 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 2C8DE3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701869050; cv=none; b=eAKoyg7Lt686IJiRLXwtx4gtD5I3JdcO+NBPFAPxKj13iYpOawYQUlZMKZxvotAkgnT0lgrhzeJdllBa0Ewy5OAB40GKVGYbzghjJgr4O/VPPRrI270ZqchGJwF7tjsShZmUGfu52DMXIvZkk2K4qonw1GrOYcNT4Kw5uaaakLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701869050; c=relaxed/simple; bh=aDVI8vHO0R86D7iGSSULp/V2VPesBPio17Dd4Rx33CE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=s0kDGcjNc8I8NLZYrIqNMiJnEK0cRMoRJLA4X/d4rWntgo7nwIhlHltd2qMLTUc4PdbBSl4zI/DXLsT+bluo7lV9up2C9BqQMGjUSjR0+Pw0g25v4eYOQr1hBJXxCaasJKEFDxXQ9u01iDogc46ML/jVUyMNt6DUT6gwJ4ePfiY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ce72faf1e8so1303461b3a.0 for ; Wed, 06 Dec 2023 05:24:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701869046; x=1702473846; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Zg1VxcADULak8GnV90JoW55uWQbZN0gZ2F2U0HD8soU=; b=Uu0g/cmY/+T1KlXmwg7bE++xhSFJPEgGszCtkPlO/jLFcCPVGlEK+gJ4EhAigDd4ah 8MAe3o5Q6uekNM3iKQ2EDZJ72WGiqp+X7PAQjsjugDL1w1E8T+gEkFpNgZGqbP84+fin dPYEM2wIYqPacIh0aZMSyx19Jp+VwtrYLfChV5AZFlbr7HbSNydsghIxx2ukNY/URsdY fqFoezHKU/KAaXBXXl8pVDq1f3i/6wjxPUmT6yPxXX3KWLwrwQoP23FcqW1X7WjcrOwG UaVfRTSTKRkv32ut1Q24PTwgfSd6dgtX5jIiWWm4tHp2iSTiC+69J1WtNgZjsDTl1v/1 GJQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701869046; x=1702473846; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zg1VxcADULak8GnV90JoW55uWQbZN0gZ2F2U0HD8soU=; b=Exgoyp3C23MJiJN+Y0KhuLPlgRT6hUEHyiPVuluIaUnpz3zj/3A8oxVP5mVqyo1dGc 95O1eokt6SpLXzM5V2J++5KNR2UlrHOjKxxAWaLkhZMnF2BXJ4TxoBUS9B+H6FNjMA03 wXYjbYJvGCqUYnQYuXFNM278Wa8K8/fsZdDkwibRAsczvwQloqxX7OCPmH3kpP818NRB c7mttWVtfHVG+Up9TADHBqOUoFUZQjVFd/7h1qz6i97hWChq5qXZrISdug5o6yt/QJES gatYBGveE9lVKblq3zOTqjwZGR4mOu5Dt/I8brrZ8TpRYeXJDVVNTRw/bZT+iwLHGeEw aCXw== X-Gm-Message-State: AOJu0YyswZlhVvpmIxH4Kzx+4sp5luCvcy/FyCe26JhR3bPZeOgQbOTM YniZR/91QBa/nfojFmvJ3CL6UBBLZvrEDj4KysE= X-Received: by 2002:a05:6a20:c19e:b0:18f:97c:8254 with SMTP id bg30-20020a056a20c19e00b0018f097c8254mr844198pzb.94.1701869046505; Wed, 06 Dec 2023 05:24:06 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:56e1:da8e:9a8e:e071:49b6]) by smtp.gmail.com with ESMTPSA id b19-20020a17090ae39300b0028672a85808sm7449168pjz.35.2023.12.06.05.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:24:05 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v6 0/2] Improve loader environment variable handling Date: Wed, 6 Dec 2023 10:24:00 -0300 Message-Id: <20231206132402.1356644-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-5.4 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, T_SCC_BODY_TEXT_LINE 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 Itremoves the tunable_strdup and make the GLIBC_TUNABLE parsing in place (no more possible allocation failure). The parsing now tracks the tunable string start and its size. The dl-tunable-parse.h adds helper functions to help to parse, like an strcmp that also checks for size and an iterator for suboptions that are comma-separated (used on hwcap parsing by x86, powerpc, and s390x). --- Changes from v5: * Only parses the alias environment variable lenght if required. * Fixed _dl_strtoul for hexa and octal inputs. Changes from v4: * Improve tunables value handling, now warnings for invalid and out of range numbers. Changes from v3: * Fixed tunable_initialize for strong aliases (it used the key length, instead of the value length). * Added a assert on tunable_str_comma_init to ensure its value is non null. * Added LD_WARN and LD_VERBOSE to filtered environment variables. Changes from v2: * Extend tst-tunables with tunables aliases tests. * Use warning instead of an error to indicate invalid tunables. * Fixed tunable_initialize for string aliases. Changes from v1: * Ignore most of the environment variables on security-sensitive mode. * Extend tests. Adhemerval Zanella (2): elf: Do not duplicate the GLIBC_TUNABLES string elf: Do not set invalid tunables values elf/dl-misc.c | 10 +- elf/dl-tunables.c | 113 ++++++------ elf/dl-tunables.h | 6 +- elf/tst-tunables.c | 96 +++++++++- sysdeps/generic/dl-tunables-parse.h | 134 ++++++++++++++ sysdeps/s390/cpu-features.c | 165 +++++++----------- .../unix/sysv/linux/aarch64/cpu-features.c | 33 ++-- .../unix/sysv/linux/powerpc/cpu-features.c | 45 ++--- .../sysv/linux/powerpc/tst-hwcap-tunables.c | 6 +- sysdeps/x86/Makefile | 4 +- sysdeps/x86/cpu-tunables.c | 118 +++++-------- sysdeps/x86/tst-hwcap-tunables.c | 148 ++++++++++++++++ 12 files changed, 592 insertions(+), 286 deletions(-) create mode 100644 sysdeps/generic/dl-tunables-parse.h create mode 100644 sysdeps/x86/tst-hwcap-tunables.c