[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] xen/common: llc-coloring: Fix off-by-one in parse_color_config()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 9 Apr 2026 14:53:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com 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=jpTCFJTNVn3cepBCTQQNLq1I8sssaVC5/ZeAGynFNfc=; b=yx08/UfeW2pVSN0zgcIoMmNbhLZiTjojs5yIh54cA+RsAGSi3I/ezIg4xOzdY+JONdZdpR9DHLsKVYWP8PT752Zz13/i/W+ASUxm5c3NtD8jR5n2Pw4mol6ko3zcnGj8TlBdgFu6rabMK3nyuenqyH9KWEDtkYiYueukZonHnDNYjq1lfuz4kRzUZlWiGZvj0Nq9plfOUovDwTVov9KQwzGEFI+C4KsM6Az2kPo74uKazZaTe0rWuoF1zUUoU1FWdKviz8sTpEv20VgBmYsnm1Wu+P+i/671wTO+7mI+a3Pz65feB7lbFevK4YsFxOmldI27txkfL7r0IGUFjQUDsQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IWGl0q7hJuK6UeMBaBvB+p5fmAJRDnr7enONSDsQS7+TKeYgpnThfiSwP3sNHFMxRODaiYlPIF6Zm5GXo36rLMDFt8rLj39qoI88be2XPtta9xUnrAtAzJNCGTVg/DyXai5hNY/Rs6te58gxNLccPuuixa3ZxFE07plRMzvG6v86gV5kCsN0Er/y9VzYZPE9VoKIss+IzYVm71/8oAXd+incrVyVsRc4mlatcaaroju1VLXarjh401WuvIs8XJsKR2di2rpljkGpdynyyYyQpsM6i3T56Fn2kcWOKp0B8Cc0EK7qXoszS/zJYZ/lnkPEQtzoyGCvnHDfFUC76CF5Iw==
  • 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: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 09 Apr 2026 12:53:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 09/04/2026 13:47, Andrew Cooper wrote:
> On 09/04/2026 12:39 pm, Michal Orzel wrote:
>> The check uses >= to compare the total number of colors against
>> max_num_colors (which is ARRAY_SIZE of the colors array).  This
>> incorrectly rejects input that would exactly fill the array.
>>
>> For example, with NR_LLC_COLORS=16, specifying 1 color for Xen and 15
>> for dom0 would fail.
>>
>> Change >= to > so that exactly filling the array is permitted.
>>
>> Fixes: 95ef5ddf8a ("xen/arm: add Dom0 cache coloring support")
>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>> ---
>>  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..30c1594dac9f 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 + 1)) > max_num_colors )
>>              return -EINVAL;
>>  
>>          /* Colors are range checked in check_colors() */
> 
> This boundary was changed by
> https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=cba8a584de171c8c4510709c2edc9f1cf86b21ab
> because it was off-by-one.
> 
> Are you saying that the analysis in that patch was wrong?
I examined the scenario that is a default for dom0 i.e. dom0 gets all the colors
by default. This is equivalent to setting dom0-llc-colors=0-15. If I set this, I
will get a message:
(XEN) parameter "dom0-llc-colors" has invalid value "0-15", rc=-22!

I admit that I added wrong example in commit msg.

~Michal

> 
> ~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.