[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: "Orzel, Michal" <Michal.Orzel@xxxxxxx>
- From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- Date: Fri, 10 Apr 2026 07:08:38 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; 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=VylMf0UBcQgkYOUdu4v1mkbxc4ELAyaRNARRuVmJ1b4=; b=Qtdk/MctZGz7MOP841bCuthAtlXH7uacwIuw23Oz9EsFoWxbI6o453dFtlK6MCtQeeN6RfHMmh2snvXb53O9GTZ8KbCe9mUzuN3z662oDeoPrHNDPZMTs+R/FcSDa7+tpa0Mtzli8m0ZCR2GB5fRy8aLFCk13i0uj/FyDbNgS+ZLzKTf+qBb4PWUGdWuUys6o+gU5SQbhtzq4Yn0koBLXqglDMFJsWtekdQqxN1d3CcoHdzzMjFMpNEeDMaPysRgiMW1JyXg2TGvd1x87XG35I3x7jtOgrB+C6JWum3Akj5y35PM59oi26frMGkPNYD3caog8Z/5e6fXkrm/kUUWrQ==
- 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=VylMf0UBcQgkYOUdu4v1mkbxc4ELAyaRNARRuVmJ1b4=; b=l15DC+xcUCKPcnnc/XLgRFwJkLCfD1TXvq5EyovCajplGoD7UBlgBsH1CzM6y4uPhkqYdVCy2T9i4ujvGy99UWHL52+m9b5Xf4hbUaKfteicW6p9IWJUVdMj2nxWKTyU3ftu8e+bPGirZ2t0/ZRe/+nfaNgSDu/c00Q5Wi97wC1tO0LN1pex2NdNkLpec1Hd+nfBZHydN03lVzmoHuqv9F+0Sh2v2tYV9imIr4E/EOFA3avptIrGv7ex6NI7zjLoTqthA+AjtdVpS+aRDDt53tTuB1C3i+rbDBh1aSibkzhTzhHilEBEQoKwQULNqjEkIngfpDODLv+D1AblBfywew==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=O3y2QPMeUoJ6oLZqpac2diVPKCo/uE20HukIzYh2zYjVBC0+5ZzHjK3aQZ942G1mOccUKhizk9ukU7tvlRD6jw7GofD8KzUHHzDeVXvWL9vl804QE+jOzljywg4KjakamJO576kN7DhJHS08TDrPHFzz+ysocsuQjzDvvkV+ySbRFThzN9BwT/35AfObLbkccyC/6gg43hCceebzGV5dcwUwKzCQ5aHExzJi8ldBK9+sogugy7Kvt6ATKyWn7ERnO+aBb3R7uNo5UDkcLHxWGSZ9Gxa7XXSTnLXWs5IjbjSYMVVTPV0NOztpEvq6by2Cg33svXRwr4AwLPSBrw3kBg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gh6ckWfjf6CvD3+lBzD7nBYlpTzq6EVQc8zTg1iq06y3yv7DWSTfh/FgFdyEoOeezpJ3e7Dk6AaM1RvdbZdkOQpMooZx2skOY9654AUp6ia1VkLpdiN1UwyjAraRDRFgvR8PCmeUhl4xupmH28teuemtAvsGZ9ZYTHIu4tKCsxxMlAbV1ES1ZhhAqfOa24okxFeb2iGIMKN2Mt/6utPzp6BdVlz2DfT8XYDu1tunrcZlGLSt46zHrC+OY9XPDLT6OiI0BV3ZzKyuhdwZJSa4Klt818tw1pDybG0TBjWUyEJDeVWGkst8xVjWzT9bds4xzFVjAsUlxCPxJCWpxg1rsg==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
- Delivery-date: Fri, 10 Apr 2026 07:09:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Thread-index: AQHcyBWdW2bjkWPifku6XWocvaXOWrXWpuWAgAAHZ4CAAADggIAAC5wAgAEjsICAAAHagIAAAQ8A
- Thread-topic: [PATCH 2/3] xen/common: llc-coloring: Fix off-by-one in parse_color_config()
> On 10 Apr 2026, at 08:04, Orzel, Michal <Michal.Orzel@xxxxxxx> wrote:
>
>
>
> On 10/04/2026 08:57, Jan Beulich wrote:
>> On 09.04.2026 15:34, Luca Fancellu wrote:
>>>> On 9 Apr 2026, at 13:52, Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>>>>> On 9 Apr 2026, at 13:48, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>>>> On 09.04.2026 14:22, Luca Fancellu wrote:
>>>>>>> On 9 Apr 2026, at 12:39, Michal Orzel <michal.orzel@xxxxxxx> 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>
>>>>>>> ---
>>>>>>
>>>>>> Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>>>>>
>>>>> Did you see Andrew's reply? If that earlier (recent) commit was wrong, I
>>>>> think a 2nd Fixes: tag may be needed here. For now I can't help the
>>>>> impression though that there might have been a re-basing mistake, where
>>>>> that re-base may have wanted to result in this patch dissolving into
>>>>> nothing. Yet of course I'm all ears to learn otherwise.
>>>>
>>>> Oh, no I didn’t see that! Thanks for pointing that out, I will have a
>>>> closer look.
>>>
>>>
>>> I had a closer look, I feel that the patch is ok and commit
>>> cba8a584de171c8c4510709c2edc9f1cf86b21ab
>>> was missing this corner case.
>>
>> If anything, that part of the change there was outright wrong (and hence, as
>> said, a 2nd Fixes: tag [actually, see below, simply another one] is needed).
>> With overflow excluded,
>>
>> (*num_colors + (end - start + 1)) > max_num_colors
>>
>> is the same as
>>
>> (*num_colors + (end - start)) >= max_num_colors
>>
>> i.e. the state before that change, isn't it?
>>
>> And yes, now that I look again I think I agree that I screwed up there. Yet
>> then the (imo) better fix would be to undo that change, rather than switching
>> from >= to > . That's one less calculation overall. Michal?
> Yes, I do agree. This patch can be modified to just do:
>
> 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() */
>
> I'll do that later on.
>
> ~Michal
>
Feel free to keep my R-by for this change.
Cheers,
Luca
|