From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IG2IKnfsR4LQM7zUdZRBwkY8uJzIUUGUYQBj1zsGakHHwwC3kdORYzwjDtLSmeSpwLT/JDpEw== 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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, } }; -- 2.34.1