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 X-Patchwork-Id: 78023 X-Patchwork-Delegate: siddhesh@gotplt.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3754A387103F for ; Tue, 17 Oct 2023 13:07:24 +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-Google-Smtp-Source: AGHT+IEAV81gF/tzRgnxeS+XeIKsGCsMvmZYMIsStFdF8OlR675bRPhBFPU9rueZvoZj3pndhVNcLw== 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+patchwork=sourceware.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, } };