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=1796387595; b=1weUZcFoO+8K5FNjTRHMDhSPE2Bjac0L7hdN6uNFbfWVIwxkJR7FKDMx6L6gObBKCRRw S1C3bcRwOdXLeK5BqOe9P8HHVbDINo6+RAB3r1w/57ssCGZ2HoTb3tPZ32mgECUilYf+t /cPmHIaICdyV8Hibk4VDAgQKNCzQIeABiDDpRp/LYiIN7m7Rt2R1gbnIPHR1k3HaQ4hS7 15mcCs3NrGjcTlMcdxpJzyx9RhZGPqhplKok5gMWrSiTTB+V/3/qJykF7qU6gNYTgH+xw ENvMIWgQA8HHR3mtw/c75zQ3Bfz/yKY3J4R93Nn6L7COLun0D8pIt3Zz3mVv8xOLAuQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387595; 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=xrYRQPOvEbrK1RJJ72E2lMBwJSyEZU5Lec1Jbj8e6Cw=; b=M6SbbowB1KkTFWjL9hnXw4JugC6x8XEco9Ho/s1rl+JfgtlLk2qmq2kXxcGsGIPTide1 /KpqmRjdMgl5Do2Hfx6Ai4LjVrurKjZix+HsPVDNTGviZgdZISw8n+KT9qLw2BLVCozuk b8a4hFmhN5m6PwZA4HDrEXqqUuqH+ZLnmgW2WmXPvhx9/U9jLgjfR1s+6n8SAzeuT2wAU KTpBPsK6J3TNnmA8257gvyNJ3ek1JybQ70ktPCTBb6T1EIT59s+2QhBSR6XNOwtEYrBEz BAvnjp/pgrWt2hsE+RpCm4kSjFaz5ewIQTMqUAM1APSKUiA6tcBcJ8+2Kzrrhdqralg== 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=L+WxLUhd; 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 8D6BC606A32D; Fri, 4 Dec 2026 12:33:15 +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=L+WxLUhd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01D301F000CE; Fri, 4 Dec 2026 12:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387595; bh=xrYRQPOvEbrK1RJJ72E2lMBwJSyEZU5Lec1Jbj8e6Cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L+WxLUhd1GP9h/2ElpYtP555qIr0lcN14QZr7Q8aCyR2U2U49WtJxfclwne6V2Xne igafibyMGPkUuMg1cnpoYclfLoVUyO9fSq3MCRY5glWRLk+30IQwwlOc/tyLGN5Qs/ 9kPLNEhR6FyugkJFyzsw0A+6BMIl32kECQuJ1CpY= 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 6.1 0309/1059] bitmap: bitmap_parselist(): reject trailing characters after group size Date: Fri, 4 Dec 2026 18:57:20 +0900 Message-ID: <20261204100652.278592991@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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 6.1-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 [ sashal: Applied the same hunk to bitmap_parse_region() in lib/bitmap.c, since the string-parsing code had not yet been split out into lib/bitmap-str.c. ] Signed-off-by: Sasha Levin --- lib/bitmap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bitmap.c b/lib/bitmap.c index d3184db294e68..9b41b17c96d32 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -765,7 +765,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