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

Re: [PATCH] radix-tree: don't left-shift negative values


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 13 Feb 2025 16:39:46 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org 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=bfWC9ZqZ4UHeqf7I0AYSJGl3vW3EU9uR590RXaMdVTo=; b=b5lqRViq5EL1+WzSvBm1wuFSqei8hx9aLDxYqU4z6PLoGFp+16k8IFDiv1RxWaOHhxWnwLUnYB/iXPlfmlYnWK/8g2lhxXM1HcKpkdwxZ4dgKq7irK+MfefzVHqWOtRB9eQOzhUOtEDDuUPmc/3eWjUjKX4ihHyrLYJTFo3HGiv4H5+ywXaKEKPYSNzOVtpGZCbpRIfc6C8SmsMQ1clhq/Ezo8wB6g2pTxrWu9sdYz6/fXPPEnVZNdE9RxRlmcHRCirHjb7LQmLiU2ZsIfgCxsgBbnDJ2gppA0VMHTr8ZQm7cMdyPUeDvdjTTjk8MX/t9hM++tkOKb/CKrjPj8V3BA==
  • 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=bfWC9ZqZ4UHeqf7I0AYSJGl3vW3EU9uR590RXaMdVTo=; b=WdSQjwK4IR65EQT1BZksCNyvEqTGxdAoU95aNL4eAYD7tk3ztn/HaSycCtyLP/9S+QVLnC3ulF+C8foXi5Cr32HIDIxdzh1RtT3SPZa9O8pu3QsCxTwXPhVw4S90SlHl2SuZ3UF1RdFoCtjU+LWzfL6vpzYChJkA2nudnTO5OrzCZHgmMFy31wvr7e6NXC6GxhTMquMZPXOaCjhll+bRqGdZW+ydJk7OuuCUtM9k06U+w2uhXsxaqxLqCe2Mu4AaoUp4q15hZsmFdA3unnqo/zCt9e4nMAPt+lZGgGWhd7t98ZgyckXyOG4YpJadnPQVy/pgq1hd6WmBEx9CcAvvUA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=aevzpFXAtz+d0tB9xkzX+9ZZrauLbDOQNXgC0SiLr+9CECJkZMdf60JA/RoRgXTy88dL/ShrUN/bKnP7F5pwHCZ0V37LmTy8fngffkOq8fIKBw+2JlltYu3pd0fG5+7HRhNwz56AF9xlpwxGv/H0GmMaLw159dEWS5r3CPdXcfTXUFCZJF2F7O8PzxLCQQS+aONNGqXP7uNo/MGcChhbZfyXvVrlNGhThG5fMVSwfG8c3My0mp06IVPpVHFssOp3TfW908GRf7KIgBinAW4n700wS46bnatbTSCaljTGfMGipI2dmAnlHyP/RbcdMD5A+TSR9tSkRuBrRvmxAjBfsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uHOYDIFxbDRX8rkOd8yuhXXA3KgX0zDMUzT6OUwaXLkDNJn26QqnDRC12Gx/umdyX5BOKZyaX8AIh575NecUX0wrMhpPTqGSaVRk9Et2CMOyNRRD/7RRr1Wf1hxo5cm9i4hdObTQjtW0kToomdhEaZoZ0iYFDYBTWTeWULWsPbWWqSZJJxRZrDMkix5GMB63ZFc1yA1ZqknWd5nxZBofaXxISzZtwoes6ZC4pW8YcqfHDYUs2lzqyqlOaveYU0hzDiRP6yhfDSh5Bcv4mLPb+45xxUZiPbRyTp6b9Qzxzah9Q7z3+c125vNJLMrMyAPGdmdJfun+D5MVdSChyYtZAw==
  • 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>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Thu, 13 Feb 2025 16:40:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHbfiyFimU3wrEce0aiTSaEa4+3C7NFX46AgAAPvQA=
  • Thread-topic: [PATCH] radix-tree: don't left-shift negative values

Hi Nicola,

> On 13 Feb 2025, at 15:42, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> wrote:
> 
> On 2025-02-13 16:32, Nicola Vetrini wrote:
>> On 2025-02-13 16:01, Jan Beulich wrote:
>>> On 13.02.2025 15:52, Nicola Vetrini wrote:
>>>> On 2025-02-13 15:22, Jan Beulich wrote:
>>>>> Any (signed) integer is okay to pass into radix_tree_int_to_ptr(), yet
>>>>> left shifting negative values is UB. Use an unsigned intermediate type,
>>>>> reducing the impact to implementation defined behavior (for the
>>>>> unsigned->signed conversion).
>>>>> Also please Misra C:2012 rule 7.3 by dropping the lower case numeric
>>>>> 'l'
>>>>> tag.
>>>>> No difference in generated code, at least on x86.
>>>>> Fixes: b004883e29bb ("Simplify and build-fix (for some gcc versions)
>>>>> radix_tree_int_to_ptr()")
>>>>> Reported-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
>>>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>>> ---
>>>>> Bugseng: Why was the 7.3 violation not spotted by Eclair? According to
>>>>>         tagging.ecl the codebase is clean for this rule, aiui.
>>>> radix-tree.{c,h} is out of scope:
>>>> automation/eclair_analysis/ECLAIR/out_of_scope.ecl:32:-file_tag+={out_of_scope,"^xen/include/xen/radix-tree\\.h$"}
>>>> docs/misra/exclude-list.json:153:            "rel_path":
>>>> "common/radix-tree.c",
>>> Is there a record of why they are excluded? Is it further explainable
>>> why exclude-list.json mentions only the .c file and out_of_scope.ecl
>>> mentions only the .h one? Shouldn't different parts be in sync?
>> exclude-list.json is used to generate a configuration file for ECLAIR just 
>> before the analysis starts, so effectively both are excluded. It's a good 
>> point however to have only one file to handle exclusions, and use that file 
>> to generate the exclusion list dynamically, but then someone might want to 
>> exclude certain files only in some analyses and not others, which is not a 
>> good fit for exclude-list.json as it is now.
>> @Stefano, thoughts?
> 
> I forgot to address the first question: the (vague) reasons are listed in 
> exclude-list.json as the "comment" field; in most cases, it's because the 
> files have been imported from Linux, but the full rationale is something that 
> should be asked to the original author, which is Luca Fancellu.

So IIRC the full rationale is that since some files are imported from Linux, we 
would like to maintain them as they are
in order to ease backports. Misra fixes can be done, but they need to be 
upstreamed to Linux and backported to Xen.

Probably a re-evaluation could be done by the maintainers to see if some of 
these files could be removed from the exclusion
list.

Cheers,
Luca


 


Rackspace

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