[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] xen/common: llc-coloring: Fix off-by-one in parse_color_config()
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Michal Orzel <michal.orzel@xxxxxxx>
- Date: Fri, 10 Apr 2026 10:29:55 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jYFPfaJPvDQsePFmi9pCijvhw7JhNcTXtcOi74pOOro=; b=w272Nqu99Gt5pyRNh7CIlJqyImCc8Wip7wTAAYXDEMC91bjPwnLnAE92BYPE0Dg6C0PMpwjTW5U5cfmna4ro/SVAzcheYx7JHVtGise/9sSO5tKIYCdXTMnGzG6jXHhDxcTL+q6rKvaIXDVYeJUS3c1D6YTkArieRevaWAmm0T6b9upS93OZRbBHCeV42rr6DnlpByWjG6D4bJLyT7wmxCSBatl4/E/jvAJ8qulDehdNC1oJn33KnemvQAc191xN8S6IaqPQXi0iUCBh2DCcjPWyj/gzlNUFoYM8mYHlY5qng/EkyutQxpCt2V2OxnRM8qTd8dcMCW+r/IGqPkn/Hg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SrjI/4ozl6CrkKsD4KTwgVkneshuHvGr4/ZBlZ/PsSehkO5ou66lTuRXuJEHI2/xxs9vqkB9SVH0fAxW0aw9t4QXRr1OVCW4ZlUaQpL0K8rTMcm0XPN2bLYJRVjWVGNY170aqoI83ZLfecOgkhNhIhruqaaV6Vmxe/wZqgSTsLj+OTL3g02KZWhSaLjI2em42eaT3ubBXvGLfhzm2lhG1ZudsRxkQbGk5sjd9BJvMMBttDSXlNq/SpChtsilpD1rZ7yndkyx1MYp7iQ2udfTAHEuhnBfo5WPSePZcA90bX/4UDef2wnCwSwPm5aGOU0thmb0xVpQrl21k3FXHrdsLA==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Cc: Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Luca Fancellu <luca.fancellu@xxxxxxx>
- Delivery-date: Fri, 10 Apr 2026 08:38:49 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
The check uses (*num_colors + (end - start + 1)) >= max_num_colors, which
rejects a configuration where exactly max_num_colors colors are specified.
For example, if max_num_colors is 4 and *num_colors is 0, a range "0-3"
gives (end - start + 1) = 4, and (0 + 4) >= 4 is true, incorrectly
returning -EINVAL.
Fix this by switching the overflow condition to the state before commit
cba8a584de17 that regressed the behavior (i.e. don't add 1).
Fixes: cba8a584de17 ("llc-coloring: improve checking while parsing")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
Changes in v2:
- extract from series
- undo the overflow change made by cba8a584de17
---
xen/common/llc-coloring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c
index eb7c72b24023..6dc614739a98 100644
--- a/xen/common/llc-coloring.c
+++ b/xen/common/llc-coloring.c
@@ -78,7 +78,7 @@ static int __init parse_color_config(const char *buf,
unsigned int colors[],
if ( end >= NR_LLC_COLORS || start > end ||
(end - start) >= (UINT_MAX - *num_colors) ||
- (*num_colors + (end - start + 1)) >= max_num_colors )
+ (*num_colors + (end - start)) >= max_num_colors )
return -EINVAL;
/* Colors are range checked in check_colors() */
--
2.43.0
|