From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795017491; b=nZ4WOUGf5z2ZWp9/767gKjyl8ri5h0EUKEWsSQf5gh6Su625lCKC3P8bEI75wsDblWNh TRwOyVUqFHXjvCqa/YqJbje5Sx24GS+71PeVv04Vf5YDgwrJqyeMDCCYb6cvdYa2KGZbw ciDpHSdXE/Cm/tOWO2W5yyxIireJw7huHM6xat5DCudH9N3FEe5pw8m7Zr0+K88MA653y 0/Va13iPnrSPe70o5QvNidSrojvsj/g3epqUMqOs6aB9IkF0NUJkBiZEBt8EDke3hGgth wf4LnP2W7AZll9XiSQEtTuYj7HReY4Zii0xnLyBTLVtywC0O/d7UquRmmEdfZ8zn4LA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795017491; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=TksRLKxX69xVWjEVr7LW6QvJo91aJSIzm+BH2h3O6uQ=; b=ifPerScAWgTBQ7bzMCDpqR7R8mTvcpoCkCLS6NQh5qJVw3lVx2E/8cK5fakLOhg+n+9h VZx90weiBi+n37ZSX0STQ5ZOxsW/TIjmFvvN7qDntvtbzpLw36ePx1/1/7zxi9Ez2pJDH 3lfgyZ9ua7iht06Ju8ZWC/8Uz3an75ol5JPGCL9wx1sTgzgLJzmJthLe4nkc6VDeMTDXp 4C5yYVYesFGCG10ngDnjUnMtdF0qY3fyE6+5qm+76eEiDjTIZFBg1A1eWRh/hbcyxY/f7 cuM29MKpA/qYhhVnnue+o0/TuR+i9RJUsgELEVoTRdxZWuW1ZyQhImi6eRuBc51Sd8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="SYirO1/t"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF4E606A325; Wed, 18 Nov 2026 15:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SYirO1/t Received: by smtp.kernel.org (Postfix) with ESMTPSA id 663C71F000C5; Wed, 18 Nov 2026 15:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795017490; bh=TksRLKxX69xVWjEVr7LW6QvJo91aJSIzm+BH2h3O6uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SYirO1/t/0bDOksmnidDxA+w8bsPWXhfv+Wso+HWM2skbiFeYBlc6UbZh8iJL+dKf N3DnhuJHioU2BWW4A5FOFPXoXHGYFsZbeYOrPKAX2m0zwli4hCdLrUUxgB8eavuU86 2ndEA/NT7lHTw11g7vRmgqm+41RDi04SXJnLJEtg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shashank Mohan Jain , Yury Norov , Sasha Levin Subject: [PATCH 7.3 0902/2651] bitmap: bitmap_parselist(): reject trailing characters after group size Date: Wed, 18 Nov 2026 15:35:42 +0100 Message-ID: <20261118150320.338984268@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shashank Mohan Jain [ Upstream commit c55d102257fa31271c6f11fea595b78c48fd7aa2 ] bitmap_parse_region() checks that every region ends at a separator (',', whitespace, '\n' or '\0'), except in the "range:used/group" form: after parsing the group size it returns the pointer to the following character without looking at it. The caller then starts a new region at that character. Before 'N' and 'all' were accepted as region starts this happened to be harmless, because any other character would fail to parse as a new region. Now text directly following the group size is silently parsed as another region: "0-7:1/2N" -> bits 0,2,4,6,7 (nbits = 8), returns 0 "0-7:1/2all" -> all bits set, returns 0 while "0-7N", "5N" or "0-7:1/2x" are correctly rejected with -EINVAL. bitmap_parselist() is documented to return -EINVAL for an invalid character. It parses cpu lists from sysfs, cgroup cpuset files and boot parameters such as isolcpus= and nohz_full=, so a typo there is accepted and yields a different mask than intended. Check for the end of the region after the group size as well, like the other forms do. Fixes: 2c4885d24e64 ("lib: bitmap: support "N" as an alias for size of bitmap") Assisted-by: LLM Signed-off-by: Shashank Mohan Jain Signed-off-by: Yury Norov Signed-off-by: Sasha Levin --- lib/bitmap-str.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c index e02c5bc80951c..b589668646574 100644 --- a/lib/bitmap-str.c +++ b/lib/bitmap-str.c @@ -299,7 +299,14 @@ static const char *bitmap_parse_region(const char *str, struct region *r) if (*str != '/') return ERR_PTR(-EINVAL); - return bitmap_getnum(str + 1, &r->group_len, lastbit); + str = bitmap_getnum(str + 1, &r->group_len, lastbit); + if (IS_ERR(str)) + return str; + + if (!end_of_region(*str)) + return ERR_PTR(-EINVAL); + + return end_of_str(*str) ? NULL : str; no_end: r->end = r->start; -- 2.53.0