From patchwork Mon Nov 6 20:25:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 741456 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1294476wrr; Mon, 6 Nov 2023 12:26:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgowxQnxdxICA45MhLxSLmoyiH46GMetuWLY0+ykmXxkh1eFh86MxSBPjnDHraZJjBPcbj X-Received: by 2002:a81:6582:0:b0:5a8:960d:e538 with SMTP id z124-20020a816582000000b005a8960de538mr12596739ywb.47.1699302401740; Mon, 06 Nov 2023 12:26:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699302401; cv=pass; d=google.com; s=arc-20160816; b=d9c1N0y2XSi7IvMOv5CAVsZ/9iFJ0LyMCVsfwA6lKJymBCu2VW+N+a9sUrjxtuBQxG kXGCtQ6CWvIt9WtECWYeLdNatn4f8h68YllImj5w2/hXj0m9gP3FStMHfjgX/aUXyxWl ojbvnRzT9ppg8FDQVySAABQT2PzDWD0t/e/vpxEdq3CNjZkqcM/Ay48h2a9Uw9vXWZ0v eLPxNjq9KnCz0+2R7PXqzP7In1kcqfodAkG4kKOyL7NCFKAAPq+HU3X6yU/EecY8r2XC mgS2ZHVryej1Q/Mjm5/gqrYutmOzIhl1NGrgHTe00Ay4P71UVemiH97XJgE9C7M1RrJ5 L94Q== 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=1RMBvWB4wasLc+bD8GbPq1agF/aX5X0iDbhrtLiLElM=; fh=+FUb54tScwW7D3lvWhZcQBi30wyNNn2DusdH7ahfqKk=; b=mIH8/1S+l2c3vJ62piJ3tnvzi+ztbAD30NB+K9fWe4scenX5fDJR5c9s6899ex1KN/ p3vrO8PaZCTH0UoxX+HQilu046hj7yGUZPZ2tHNFfLcs5rusEXUanejO1NF9llI8JyaJ lzzkp+PnAjv5ko8ePDOFg4ziJ/vNqMh+0xMGWtriXcDjC/OeXHlmaXY3TtU67MgFtqJO XOYmuRTOOp5x3SD5zJgX3SFKBrrOBR+2fZPowsA7Ywoeok6mEG7Z3pIDTg8dlN3j1io4 kPGES8TVV1LTHL0mVIg/5DPOHVt2tJY2MsdxQZja0pyXnjG/bHidi4fTOlwrvVopkWrg kybw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QIKdwLLZ; 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 s3-20020ad44383000000b00670bfa946dcsi6151405qvr.258.2023.11.06.12.26.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:26:41 -0800 (PST) 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=QIKdwLLZ; 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 41BD3385C426 for ; Mon, 6 Nov 2023 20:26:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by sourceware.org (Postfix) with ESMTPS id 66E283858005 for ; Mon, 6 Nov 2023 20:26:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66E283858005 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 66E283858005 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302370; cv=none; b=Fw8z+1YMM2q2PU0luSp9cQHIyQkfz9qigeFUhhMDpoMysH8XWPPsqqhG0ElR0EzyBzZ0KMZ2GwZRTWxGhXS4SYtv1PcH0gkSMv8+o13jPcazpsvLlUGam+v7AA80i2K37fvxiX4Pq62Yno+QfDjCmMRZE+0rpjbig2/8jm+L0ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699302370; c=relaxed/simple; bh=uoc3mmqR0sF7e8zW7jAFwP1h8r5hD6VqCfVFd1iIYDU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qiv4PPrZ46ZBLOWDS/zXawZdgu88mQLZV1az3osfGdHa3q3TYNtoYgvbyHHUVCkcdRcXShGNIJlMgTYxxbzBs3V0V8fUtdeFbvVhBiFYm25e/6Sf4BmBcAPeeaW0DZeX4mmY6FmeDuCYdcrwhm6kpLLrNZ6Lne4uUK/Sd6V1KeQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5a81ab75f21so59070567b3.2 for ; Mon, 06 Nov 2023 12:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699302368; x=1699907168; 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=1RMBvWB4wasLc+bD8GbPq1agF/aX5X0iDbhrtLiLElM=; b=QIKdwLLZHujFlgaUxHP73YUJKr8LQjuG1TCRBK/gX8E7avPndyDsA3tEjy4sXSFNaZ PFtrDptiZPOp7oz49QoZv64+CuZY9SiWZt0rR8Q4+7n0qwR154RLVowYvRuei3J+F/LQ L0gHveZAw1qBWL0rsO0GnrPSAg052r+3PwbcylnU8tR4+WrfF+SsDq6lgE32YvlEN+XC uOdVI3BEheyYbUrm854XHLDoggpFYx+RSdtRUjTa6+5lgfX0t4HOgUMLcmYXHzIQdusq BBBQST8cOHAE0LRHGEuTnyHVl/nQ3cweUpCK6uWJ2d1xWF5Xyzn3j0k2WOAc2ZvqdQU8 L86Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699302368; x=1699907168; 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=1RMBvWB4wasLc+bD8GbPq1agF/aX5X0iDbhrtLiLElM=; b=Arbe3VKpYYOKsn+8wvEs2gdsvZbBgfbyvRw3RFAXB6e1AKK/wcPaGo1ybP+QePxGsp l5mBh6GPIQZevdNmFBlfovZzwD2IMOb6VFtfEhk/oxxjXOgh6gFNAZo0pZZV4avxyRs7 Z4YH7DhaDFcZ5y0ne+Md53pEkbRGdO/CN2jpj8R56MgQd+geIe7zCZKFPqV1EhKUpDTr duPPzjFWW6rG1I9i8ksxlVoX7nij3VBEQlRgP5hgUVRm7feL01Cf6TacXB8ZNyuL32V6 sNtzhnyTqaGHXQdt24J1IAtQFacuyqAgx17aW1V/REqmuomGVKULGmXFC6BNMRiZaptr JmZw== X-Gm-Message-State: AOJu0YwSNDgmmjN5hxiosPpt6G3HpjtmJx8BvWQaTnp/v2UA05aVPlRC i5jTjPC2erkxDSpW1FywxTHoMSIFmAbhhYYPtdaTDQ== X-Received: by 2002:a0d:d48a:0:b0:5ad:4975:c860 with SMTP id w132-20020a0dd48a000000b005ad4975c860mr12086159ywd.39.1699302368316; Mon, 06 Nov 2023 12:26:08 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a715:c1a0:7281:6384:2ee9]) by smtp.gmail.com with ESMTPSA id ci7-20020a05690c0a8700b005a7b8fddfedsm4707154ywb.41.2023.11.06.12.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:26:07 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH v3 05/19] elf: Do not process invalid tunable format Date: Mon, 6 Nov 2023 17:25:38 -0300 Message-Id: <20231106202552.3404059-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106202552.3404059-1-adhemerval.zanella@linaro.org> References: <20231106202552.3404059-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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, T_SCC_BODY_TEXT_LINE 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. 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 f7dca8f7c1..082a76d9c4 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 d874b73b68..7fe9907e05 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, } };