From patchwork Tue Oct 17 13:05:12 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: 734388 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp468994wro; Tue, 17 Oct 2023 06:07:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqhrzRkSoFJTG+DGGyCF/rYkOjUUf3+QeiLbIPWwhJME+r4c5OvwtH4A9T9FuOuMGNjIlM X-Received: by 2002:a67:f24d:0:b0:457:bdbf:8c89 with SMTP id y13-20020a67f24d000000b00457bdbf8c89mr2085821vsm.34.1697548044010; Tue, 17 Oct 2023 06:07:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697548043; cv=pass; d=google.com; s=arc-20160816; b=GHaNNPIErwn9i6xWKkmpXrRTMfpWqimvIL9k1oGIUEOhRiL/ind1o92utcrPb/mnRM 08Wps2ISlkxc3NZL4Q1lnn/5aOOlRUDO+4zfAnY9naEYXmd64SeR3KMh1aE9+ESm5+16 LqF1VouERlmHaUU4jc3X80eXuFX+KNlfgFw5zvvsiwN6koGU4X5qrhMkB4xA+KpVmOGu Mjsx+J6YJGN8jJDKu5S3RYi0IyCMz4EvImQ6yCQXuMz+UeSuiWSa3l2JNIMNAQGiyT+q JNia9NYyW1hjFVOt6VZWmgRPeP9ckNynVVqKsDhodJLZXrpPuNQo1pSbI6vpCvF8UUkS +yBA== 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=8j0ZQlnbnSkGsvZ61E1eImsFj7TkGLfndOQXbA3pkNc=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=BhzlmKSd868k3vU5GxL7HsC31jz23VG5UsT5PcAmmn5zaEysyZMAPpFKA8wwbjnUop sdX8nmyt53G5H53cJvaPTQFOmSdXt0Mo290HArFCiRZJ68sUk6ldRb56OAoGm2JglM9c tV96BJ89FVdE/infQ6fVZi+iPAxlCd60YXPeJfJFHVvqN3oCGiMhF9oUVRgDMOWZJgQt BGrdJoFy3j26SnmVrqu3kTPsvV0bFDBzadotcX0wUsC3+qRQWtgaIDx2ltmJ2tbhnUWc yw+IEEHGfuwjtfBdaRCShuPwdjoY0TkTN7AcU84JcM/LEX98oqZ+OaeKZBRsYuH8lwBQ Y0iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FMjOrVi8; 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 z21-20020a056102067500b00457ba3a7bf4si111172vsf.70.2023.10.17.06.07.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:07:23 -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=FMjOrVi8; 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 3EE69387103F for ; Tue, 17 Oct 2023 13:07:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id E2EE8385843A for ; Tue, 17 Oct 2023 13:06:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2EE8385843A 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 E2EE8385843A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697547988; cv=none; b=tMJv/bYo7Wa88walq1jkBDD4ZPD4rcX+0hcmaC6uyFPFMFka2ZHlIXmKglyZLXcXR6oY+ggdaOX4ccmNGYVMlMTaawVVuO96aciNmK9SPLHTuk6COss/ZRsXXpu8GbnImbTdVaDtUKVc+wjiHyc8SYqn2s17cU+Win7dtk7i2bg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697547988; c=relaxed/simple; bh=WfgICmcstkAiO8+77avSsD2sXNxAWcTjcNqHCajuv74=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=G+E5K26ldqGDUG/xhxmre223Be2waP2ygozo1jELgg1OFB5DzrDLndOmc84tRAGfnWDMM1fehPS1GvkdbSORcGmlEeHtJiEOZUglUe7CCJJVSsSkcmLNsVR3v/ZhUCZdSpp9i8NrF3SahR72sFj3EGYKcQfv4GhfS84M5zT+XVY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5859d13f73dso3558940a12.1 for ; Tue, 17 Oct 2023 06:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697547985; x=1698152785; 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=8j0ZQlnbnSkGsvZ61E1eImsFj7TkGLfndOQXbA3pkNc=; b=FMjOrVi8zcNrbJ67+XoL3xxYrPsDaBKSDIVctWI91UAYdXzWROWaYjeUCE+anxvIfu N3DK0wxdw1Zy1WU9VKx4OKJh5S+LuSXS3llRJYG06eVnP/tqZOznE0n7P9BoxlPy6/Oe RoVPC+lVae06FqP44QKt6CtPS3KI2sXHx73VnZc9X+9dpGPjk5P+D6Z4ODVetV+pnxVO CosDq48cJzlT6dSwIiQmcUWynt1jx4y59LR+jGZkjoUgwFrpBs4Adl6KTY62Ffgo3XCX ntUU+SM/OYsPblAK44vi2nJG0Wq1HUmG7GvkZ6wz6oJdqstRLOnP3Nx+hW9FdJAp9/rS +Kjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697547985; x=1698152785; 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=8j0ZQlnbnSkGsvZ61E1eImsFj7TkGLfndOQXbA3pkNc=; b=P3mED1rzKxB9n49i9vHGBQHF5U20MwWHaQTm7vY7Awdx2ppwKF0rFj/awzYn2+UnNP Q9t+VmNnofIytUdH1RjBcCIKWuZfyZGo1GGrAVHWVlPXP8fMUXQC8cMqA0xueRbGru1d u77vVJSQJJAiRn9rXV2shYnQPy9xmlN6pXWdLGQkbgqi4WXz+0T+9d6hF5euOxZ+zMVe +hkYJVtYQSYbMkZUdfeSPyIMZ32cPCcb563REBdBe3K18HkPgF6a1ltZ1njiTMV6AYaA SctUeW5q59weXIjUh3Dv6sVJs2DSDYdgxIb0j8f9v1s6I9Wd0U/fHnIeuWNB+muNWVdA Dn/g== X-Gm-Message-State: AOJu0YySUvK+KA32uY1zyVVimFigqRW87OEHBTphy8HpvhkJs7c+Znoy HXgThuXFnRB99VNCFtAdxhMtKyAsu7Y6JfQTusWErA== X-Received: by 2002:a05:6a20:6a13:b0:16c:d50:91b6 with SMTP id p19-20020a056a206a1300b0016c0d5091b6mr2369249pzk.5.1697547985289; Tue, 17 Oct 2023 06:06:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:06:24 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v2 05/19] elf: Do not process invalid tunable format Date: Tue, 17 Oct 2023 10:05:12 -0300 Message-Id: <20231017130526.2216827-6-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.7 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=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 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. Reviewed-by: Siddhesh Poyarekar --- 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 57cf532fc4..03039b5260 100644 --- a/elf/tst-tunables.c +++ b/elf/tst-tunables.c @@ -161,24 +161,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, } };