All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	consulting@bugseng.com,
	Stefano Stabellini <sstabellini@kernel.org>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	roger.pau@citrix.com, George Dunlap <george.dunlap@citrix.com>,
	Wei Liu <wl@xen.org>
Subject: Re: MISRA C:2012 D4.11 caution on staging
Date: Wed, 11 Oct 2023 09:47:28 +0200	[thread overview]
Message-ID: <baa73fa24385b39bc6e82c4ccb08bd13@bugseng.com> (raw)
In-Reply-To: <61f04d4b-34d9-4fd1-a989-56b042b4f3d8@citrix.com>

On 11/10/2023 02:15, Andrew Cooper wrote:
> On 10/10/2023 5:31 pm, Nicola Vetrini wrote:
>> Hi,
>> 
>> as you can see from [1], there's a MISRA C guideline, D4.11, that is
>> supposed to be clean
>> (i.e., have no reports), but has a caution on an argument to memcpy
>> (the second argument might be null according to the checker, given a
>> set of assumptions on
>> the control flow). To access the report just click on the second link
>> in the log, which should take you to a webpage with a list of
>> MISRA guidelines. Click on D4.11 and you'll see the full report, which
>> I pasted below for convenience.
>> 
>> If the finding is genuine, then some countermeasure needs to be taken
>> against this
>> possible bug, otherwise it needs to be motivated why the field
>> config->handle can't
>> be null at that point.
>> The finding is likely the result of an improvement made to the
>> checker, because the first
>> analysis I can see that spots it happened when rc1 has been tagged,
>> but that commit does not
>> touch the involved files.
>> 
>> [1] https://gitlab.com/xen-project/xen/-/jobs/5251222578
> 
> That's a false positive, but I'm not entirely surprised that the 
> checker
> struggled to see it.
> 
> First,
> 
> ASSERT(is_system_domain(d) ? config == NULL : config != NULL);
> 
> All system domains (domid >= 0x7ff0, inc IDLE) pass a NULL config.  All
> other domains pass a real config.
> 
> Next,
> 
> /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. 
> */
> if ( is_system_domain(d) && !is_idle_domain(d) )
>     return d;
> 
> So at this point we only have the IDLE domain and real domains.
> 
> And finally, the complained-about construct is inside an:
> 
> if ( !is_idle_domain(d) )
>     ...
> 
> hence config cannot be NULL, but only because of the way in which
> is_{system,idle}_domain() interact.
> 
> ~Andrew

Ok. I think this should be documented as a false positive using the 
comment deviation mechanism
in the false-positive-eclair.json file (once a name for the prefix is 
settled on in the
other thread).

-- 
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)


  reply	other threads:[~2023-10-11  7:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10  9:31 MISRA C:2012 D4.11 caution on staging Nicola Vetrini
2023-10-11  0:01 ` Stefano Stabellini
2023-10-13  9:23   ` Julien Grall
2023-10-11  0:15 ` Andrew Cooper
2023-10-11  7:47   ` Nicola Vetrini [this message]
2023-10-11  7:51     ` Andrew Cooper
2023-10-13  9:27       ` Julien Grall
2023-10-13 15:11         ` Nicola Vetrini
2023-10-16 18:06           ` Julien Grall
2023-10-17  6:11             ` Jan Beulich
2023-10-17 13:28               ` Julien Grall
2023-10-18 12:30                 ` Nicola Vetrini
2023-10-18 12:38                   ` Julien Grall
2023-10-18 12:52                     ` Nicola Vetrini
2023-10-18 13:02                       ` Julien Grall
2023-10-18 21:33                         ` Stefano Stabellini
2023-10-23 10:34                           ` Nicola Vetrini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=baa73fa24385b39bc6e82c4ccb08bd13@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=consulting@bugseng.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.