From patchwork Tue Oct 10 18:01:05 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: 731464 Delivered-To: patch@linaro.org Received: by 2002:ab3:7922:0:b0:23f:8cfb:5ad7 with SMTP id j2csp2263253ltl; Tue, 10 Oct 2023 11:02:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNMpIFViR4hv9arf2uNZ0xtnb4OPuEjhlz9qbIlEh5mxyxafbWVxXDR51u0P/AdXtXHNG7 X-Received: by 2002:a17:907:9724:b0:9b2:a7db:9662 with SMTP id jg36-20020a170907972400b009b2a7db9662mr20473651ejc.12.1696960949883; Tue, 10 Oct 2023 11:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696960949; cv=none; d=google.com; s=arc-20160816; b=RsfJr2Pq/LjswvjEApJv2FGAnAy/ipkxEu0OgQ5vj4kFwp+f9ppG0X7QRmD2s+4450 YbjvzQ4yphPH4uLjSoLnPKxl80CXWdYl2/h/Cq5GkCedG8REERZGiK7MVrtxKpo3aucj TJqdDU/K7kBEGSys6H/vs5K3zB3kZe+jVx/CeXKoqJewFzimvWLPQx/Mfc5L5RCYXR2T ZxQwH6k1Y9AKm0VMfT5oSyYDSMkZ73aj78JjjaMp5ib+5DDqFo+8/EbqtnxjooUaUgqR M9YjEjjhIEyvRBugtag+hRPm/TbYFkwP9zbQb9DTP0Q9v9DeMTDx4aaIwLgvm4d8q+Sd wWsw== 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=iRI8oW0N6EiQUSjN4FiZkkX/d9e9EgcTr+GJT9HDtrw=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=DPuT3U7FMMa1REClqL3C3WgKCr/zjrtosei+83ac3v6hQ6HvCx+AqaNNvRxwvQ3iHv 1wscHgHaQ3bxQLMT3Z0RzzrvT4vVaKs9rWFS8sCU4PPLWJ/OdueGISWYnWra3xNTC/FX bvGbp8/uuHZKmxap6gCXon1A78tYrHYku8kmReKLePfWPkcM4xljC6OtiyxLaFzbCIy9 nred/+q+Mhwssq55Nt7cqmDp8SdzYVHe/edsD98thuCdloPy6Mn+26KX94v5w+h5+Gcl nAVJPI8j+Y0AuCfsi6u5q+P4EpOe+cz8qE4qcgJLxX2wpOe2OFpyl+2CzUV5Sr57UvYv XmyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kTL5TIUJ; 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 g18-20020a17090613d200b009b30092a2ffsi5200857ejc.927.2023.10.10.11.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:02:29 -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=kTL5TIUJ; 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 522AC385C6E6 for ; Tue, 10 Oct 2023 18:02:23 +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 1650E385C422 for ; Tue, 10 Oct 2023 18:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1650E385C422 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-1c60778a3bfso49655035ad.1 for ; Tue, 10 Oct 2023 11:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696960888; x=1697565688; 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=iRI8oW0N6EiQUSjN4FiZkkX/d9e9EgcTr+GJT9HDtrw=; b=kTL5TIUJt1sxGX0KckT+AIcWJOMBox9OPx4LeLF8yGfd4JEzTTT20cPxt5VOQkLXay l3a5wFyeUw/Vdck3oFpuEOT1HdD9WmenxT3xhGwOl3fKVsT61UQYPlfyHv0wuwwb1OIy g6C9ItXTkl8AvjfBeSYar2hmU0/yxEP/F32cmZHJwC7GkkBWyyEWwjHFNvGNIKDVCorP GX6FZbKXAbJXSg1pmwqLxiHLj6PwbdANNF8fGI6kvh+ShYwVnPS76L6EehluOR1HZ/AJ tr84wnH6vIaMTRLLdF0I9dHNv9QxvGZKFL2g2z/ZFgoI5s7aUUz2Prb7OCET7c40LW4C OfVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696960888; x=1697565688; 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=iRI8oW0N6EiQUSjN4FiZkkX/d9e9EgcTr+GJT9HDtrw=; b=rEhvoshdeAS03H4E+uZE8Qz4Wo/0mBopwyqIGsPubQ8mZ3DDUT14ZShSBMiO0wlra+ IUSHYJI+fN6o+aQSB82iKo3PVSHOsaKnDptFMl9JBeXkPyqGRn7pJlNJCUUq3gdc3Iyj NGztMxiPU3um7qrOft9kPLbBbRCT1p9lINLe8bGPo/sMDid5eEk/LU/uWHgkxAlejCfn qZsK7e5huMgYDm0Vpc1cEEm09lOB9/bBL5ma53LxcrPV/v+km76zo5NmDQNRpdn4+Ul9 gnxpkG1pAZOZYyrODXQkDYa/GP6lhyH35+DbfFVNcLdoBZnKxFdofXpYodUwusEF8a+y dH+w== X-Gm-Message-State: AOJu0YzjLFZrqfxtgpscgeRNVbScdEjUeY89mUZ/nQfKr84Mjzqc0buq DIUu98duj3rT/USnve8DaFJBMSE4cnuXsBRHu7oQpg== X-Received: by 2002:a17:902:d508:b0:1c8:77f2:7d03 with SMTP id b8-20020a170902d50800b001c877f27d03mr21955806plg.45.1696960888542; Tue, 10 Oct 2023 11:01:28 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:01:27 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH 05/11] elf: Do not process invalid tunable format Date: Tue, 10 Oct 2023 15:01:05 -0300 Message-Id: <20231010180111.561793-6-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 Tunable definitions with more than one '=' on are parsed and enabled, and any subsequent '=' are ignored. It means that tunables in the form 'tunable=tunable=value' or 'tunable=value=value' are handled as 'tunable=value'. These inputs are likely user input errors, which should not be accepted. Checked on x86_64-linux-gnu. --- elf/dl-tunables.c | 6 ++++-- elf/tst-tunables.c | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index a83bd2b8bc..59bee61124 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -192,10 +192,12 @@ parse_tunables (char *valstring) const char *value = p; - while (*p != ':' && *p != '\0') + while (*p != '=' && *p != ':' && *p != '\0') p++; - if (*p == '\0') + if (*p == '=') + break; + else if (*p == '\0') done = true; else *p++ = '\0'; diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c index d6d3bea2f7..c8546b75c7 100644 --- a/elf/tst-tunables.c +++ b/elf/tst-tunables.c @@ -160,24 +160,36 @@ static const struct test_t 0, 0, }, - /* The ill-formatted tunable is also skipped. */ + /* If there is a ill-formatted key=value, everything after is also ignored. */ { "glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096:glibc.malloc.check=2", - 2, + 0, 0, 0, }, - /* For an integer tunable, parse will stop on non number character. */ { "glibc.malloc.check=2=2", - 2, + 0, 0, 0, }, { "glibc.malloc.check=2=2:glibc.malloc.mmap_threshold=4096", + 0, + 0, + 0, + }, + { + "glibc.malloc.check=2=2:glibc.malloc.check=2", + 0, + 0, + 0, + }, + /* Valid tunables set before ill-formatted ones are set. */ + { + "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096=4096", 2, - 4096, + 0, 0, } };