Skip to contentSkip to conversation

MISRA C:2012 D4.11 caution on staging

DISCUSSION Nicola Vetrini 5 participants 17 messages Oct 10, 2023 – Oct 23, 2023

lore
Share & tools
lore
#0 lore raw

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

caution for MC3R1.D4.11 untagged
xen/common/domain.c:758.27-758.40:
[59] null pointer passed as 2nd argument to memory copy function xen/common/domain.c:590.10-590.15:
[1] assuming 'config' is null xen/common/domain.c:593.10-593.44:
[2] assuming the condition is false; taking false branch <preprocessed xen/common/domain.c>:11332.10-11332.50:
preprocessed tokens
xen/include/xen/types.h:31.23:
expanded from macro `NULL' xen/common/domain.c:603.12-603.27:
[3] '?' condition is true
<preprocessed xen/common/domain.c>:11336.37-11336.52:
preprocessed tokens
xen/include/xen/compiler.h:21.43:
expanded from macro `unlikely' xen/include/xen/lib.h:26.15-26.28:
expanded from macro `ASSERT' xen/include/xen/lib.h:26.26:
expanded from macro `ASSERT' xen/common/domain.c:603.5-603.65:
[4] taking false branch
<preprocessed xen/common/domain.c>:11336.10-11336.11:
preprocessed tokens
xen/include/xen/lib.h:26.10-26.11:
expanded from macro `ASSERT' xen/common/domain.c:603.5-603.65:
[5] loop condition is false: exiting loop <preprocessed xen/common/domain.c>:11336.5-11336.6:
preprocessed tokens
xen/include/xen/lib.h:26.5-26.6:
expanded from macro `ASSERT' xen/common/domain.c:605.10-605.15:
[6] 'config' is null
xen/common/domain.c:605.5-605.6:
[7] taking false branch xen/common/domain.c:615.10-615.14:
[8] 'domid' is not equal to 0 xen/common/domain.c:615.24-615.28:
[9] 'domid' is not equal to hardware_domid xen/common/domain.c:615.5-615.6:
[10] taking false branch xen/common/domain.c:624.5-624.44:
[11] taking false branch
<preprocessed xen/common/domain.c>:11356.10-11356.11:
preprocessed tokens xen/include/xen/trace.h:86.9-86.10:
expanded from macro `TRACE_varD' xen/include/xen/trace.h:94.5-94.22:
expanded from macro `TRACE_1D' xen/common/domain.c:624.5-624.44:
[12] loop condition is false: exiting loop <preprocessed xen/common/domain.c>:11356.5-11356.6:
preprocessed tokens
xen/include/xen/trace.h:85.5-85.6:
expanded from macro `TRACE_varD' xen/include/xen/trace.h:94.5-94.22:
expanded from macro `TRACE_1D' xen/common/domain.c:630.5-630.39:
[13] assuming 'prof' is null; taking true branch <preprocessed xen/common/domain.c>:11362.111-11362.115:
preprocessed tokens xen/include/xen/spinlock.h:114.14-114.18:
expanded from macro `spin_lock_init_prof' xen/common/domain.c:630.5-630.39:
[14] execution continues on line 631
<preprocessed xen/common/domain.c>:11363.104-11363.108:
preprocessed tokens xen/include/xen/spinlock.h:119.13-119.17:
expanded from macro `spin_lock_init_prof' xen/common/domain.c:631.5-631.43:
[15] assuming 'prof' is null; taking true branch <preprocessed xen/common/domain.c>:11367.115-11367.119:
preprocessed tokens xen/include/xen/spinlock.h:114.14-114.18:
expanded from macro `spin_lock_init_prof' xen/common/domain.c:631.5-631.43:
[16] execution continues on line 632
<preprocessed xen/common/domain.c>:11368.112-11368.116:
preprocessed tokens xen/include/xen/spinlock.h:119.13-119.17:
expanded from macro `spin_lock_init_prof' xen/common/domain.c:642.24-642.36:
[17] '?' condition is true
<preprocessed xen/common/domain.c>:11377.92:
preprocessed tokens
xen/include/xen/bitmap.h:97.9:
expanded from macro `BITMAP_LAST_WORD_MASK' xen/include/xen/nodemask.h:238.29-238.63:
expanded from macro `NODE_MASK_LAST_WORD' xen/include/xen/nodemask.h:244.43-244.61:
expanded from macro `NODE_MASK_ALL' xen/common/domain.c:662.5-662.6:
[18] taking false branch

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#1 lore raw

Hey Julien, please double-check what I am writing below

Quoted 23 lines · Nicola Vetrini

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.

Quoted 5 lines

[1] https://gitlab.com/xen-project/xen/-/jobs/5251222578

caution for MC3R1.D4.11 untagged
xen/common/domain.c:758.27-758.40:
[59] null pointer passed as 2nd argument to memory copy function

This looks like a genuine issue: in domain_create, config->handle could be uninitialized. For example, domain_create can be called from xen/arch/arm/domain_build.c:create_domUs, passing &d_cfg, and I don't see where we initialize d_cfg.handle.

This was just by code inspection. Julien, did I miss anything?

#3 lore raw
In reply to Nicola Vetrini
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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

#4 lore raw
Quoted 46 lines · Andrew Cooper
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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:

Quoted 7 lines

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).

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#5 lore raw
Quoted 53 lines · Nicola Vetrini
Quoted 52 lines · Andrew Cooper
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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.

Quoted 8 lines
Quoted 1 line

~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).

Yeah - I was expecting that.

This code is mid-cleanup (in my copious free time, so not for several releases now...) but even when it is rearranged sufficiently for IDLE to have an earlier exit, I still wouldn't expect a static analyser to be able to recognise this as being safe.

~Andrew

#2 lore raw
In reply to Stefano Stabellini
Quoted 1 line · Stefano Stabellini

Hey Julien, please double-check what I am writing below

Hi Stefano,

Quoted 31 lines · Nicola Vetrini
Quoted 23 lines

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.

Quoted 5 lines

[1] https://gitlab.com/xen-project/xen/-/jobs/5251222578

caution for MC3R1.D4.11 untagged
xen/common/domain.c:758.27-758.40:
[59] null pointer passed as 2nd argument to memory copy function

Quoted 6 lines

This looks like a genuine issue: in domain_create, config->handle could be uninitialized. For example, domain_create can be called from xen/arch/arm/domain_build.c:create_domUs, passing &d_cfg, and I don't see where we initialize d_cfg.handle.

This was just by code inspection. Julien, did I miss anything?

cfg->handle is an embedded array. It will get automatically initialized to zero as we are using:

d_cfg = { ... };

Now, looking through the steps of the analysis [1], there is something odd.

The code looks like this:

if ( !is_idle_domain(d) )
...

if ( err = arch_domain_create(... ) != 0 )
...

init_status |= ...

if ( !is_idle_domain() )
...

One the first if, Eclair assumes that the domain is equal to 32767 (e.g. idle domain):

[27] field 'domain_id' is equal to 32767

But then on third if, we have:

[30] assuming field 'domain_id' is not equal to 32767; taking true branch

So the question is why did Eclair think 'domain_id' changed?

Cheers,

[1] https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/xen/ECLAIR_normal/4.18.0-rc2/ARM64/5251222578/PROJECT.ecd;/sources/xen/common/domain.c.html#{%22select%22:true,%22selection%22:{%22hiddenAreaKinds%22:[],%22hiddenSubareaKinds%22:[],%22show%22:false,%22selector%22:{%22enabled%22:true,%22negated%22:true,%22kind%22:0,%22domain%22:%22kind%22,%22inputs%22:[{%22enabled%22:true,%22text%22:%22caution%22}]}}}

Here it detects

Signature · 1 line
Julien Grall
#6 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 63 lines · Andrew Cooper
Quoted 53 lines · Nicola Vetrini
Quoted 52 lines · Andrew Cooper
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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.

Quoted 8 lines
Quoted 1 line

~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).

Quoted 6 lines

Yeah - I was expecting that.

This code is mid-cleanup (in my copious free time, so not for several releases now...) but even when it is rearranged sufficiently for IDLE to have an earlier exit, I still wouldn't expect a static analyser to be able to recognise this as being safe.

Looking through the analysis, I think Eclair properly detect the IDLE domain. But it thinks the domain ID has changed mid function (see my other reply to Stefano).

So we can return early for the IDLE domain, then this should silence Eclair. That said, it is unclear to me why it thinks the domain_id can change...

A simple way to fix it would be to have a local boolean that will be used in place of is_idle_domain(d). This should help Eclair to detect that a domain cannot change its ID in the middle of domain construction.

Cheers,

Signature · 1 line
Julien Grall
#7 lore raw
Quoted 73 lines · Julien Grall

Hi Andrew,

Quoted 63 lines · Andrew Cooper
Quoted 53 lines · Nicola Vetrini
Quoted 52 lines · Andrew Cooper
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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.

Quoted 8 lines
Quoted 1 line

~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).

Quoted 6 lines

Yeah - I was expecting that.

This code is mid-cleanup (in my copious free time, so not for several releases now...) but even when it is rearranged sufficiently for IDLE to have an earlier exit, I still wouldn't expect a static analyser to be able to recognise this as being safe.

Quoted 8 lines

Looking through the analysis, I think Eclair properly detect the IDLE domain. But it thinks the domain ID has changed mid function (see my other reply to Stefano).

So we can return early for the IDLE domain, then this should silence Eclair. That said, it is unclear to me why it thinks the domain_id can change...

Well, the implementation of the directive has best-effort precision, therefore false positives like this one are possible. Since Andrew argued that the path is indeed safe, I think it's best to deviate this as such, since other minimal changes could also make this one resurface in the future.

Quoted 6 lines

A simple way to fix it would be to have a local boolean that will be used in place of is_idle_domain(d). This should help Eclair to detect that a domain cannot change its ID in the middle of domain construction.

Cheers,

I think only conditions are checked to get the possible code paths, to have a reasonable tradeoff between speed and analysis precision. Therefore, it's quite possible that it would give the same caution.

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#8 lore raw

Hi Nicola,

Quoted 83 lines · Nicola Vetrini
Quoted 73 lines · Julien Grall

Hi Andrew,

Quoted 63 lines · Andrew Cooper
Quoted 53 lines · Nicola Vetrini
Quoted 52 lines · Andrew Cooper
Quoted 23 lines · Nicola Vetrini

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.

Quoted 1 line

[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.

Quoted 8 lines
Quoted 1 line

~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).

Quoted 6 lines

Yeah - I was expecting that.

This code is mid-cleanup (in my copious free time, so not for several releases now...) but even when it is rearranged sufficiently for IDLE to have an earlier exit, I still wouldn't expect a static analyser to be able to recognise this as being safe.

Quoted 8 lines

Looking through the analysis, I think Eclair properly detect the IDLE domain. But it thinks the domain ID has changed mid function (see my other reply to Stefano).

So we can return early for the IDLE domain, then this should silence Eclair. That said, it is unclear to me why it thinks the domain_id can change...

Quoted 4 lines

Well, the implementation of the directive has best-effort precision, therefore false positives like this one are possible. Since Andrew argued that the path is indeed safe, I think it's best to deviate this as such, since other minimal changes could also make this one resurface in the future.

If Eclair always reported the false positive, then I would have agree that deviating would make sense. But you said this was due to an improvement in the checker.

I expect improvement in the checker to reduce the number of false positive, not introducing new ones. So I think we need to understand what changed.

Quoted 11 lines
Quoted 7 lines

A simple way to fix it would be to have a local boolean that will be used in place of is_idle_domain(d). This should help Eclair to detect that a domain cannot change its ID in the middle of domain construction.

Cheers,

I think only conditions are checked to get the possible code paths, to have a reasonable tradeoff between speed and analysis precision. Therefore, it's quite possible that it would give the same caution.

What I want to avoid is adding a SAF-* every time there are an update to Eclair that reports more false positive. This will make the code more difficult to read.

Instead, it would be best to find a way to help Eclair to detect this is not an issue and also improve readability. Would the following help Eclair?

xen/common/domain.c +2 -0
index 30c227967345..ab16124eabd6 100644
@@ -671,6 +671,8 @@ struct domain *domain_create(domid_t domid,
 
     if ( !is_idle_domain(d) )
     {
+        ASSERT(config);
+
         watchdog_domain_init(d);
         init_status |= INIT_watchdog;
 

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw
Quoted 8 lines · Julien Grall

Instead, it would be best to find a way to help Eclair to detect this is not an issue and also improve readability. Would the following help Eclair?

xen/common/domain.c +0 -0
index 30c227967345..ab16124eabd6 100644

xen/common/domain.c struct domain *domain_create(domid_t domid, · line 677

Quoted 7 lines
xen/common/domain.c +2 -0
@@ -671,6 +671,8 @@ struct domain *domain_create(domid_t domid,
 
      if ( !is_idle_domain(d) )
      {
+        ASSERT(config);
+
          watchdog_domain_init(d);
          init_status |= INIT_watchdog;

Just to mention it: Even if right now it turned out to help, it wouldn't once release builds are also checked.

Jan

#10 lore raw

Hi Jan,

Quoted 10 lines · Jan Beulich
Quoted 9 lines · Julien Grall

Instead, it would be best to find a way to help Eclair to detect this is not an issue and also improve readability. Would the following help Eclair?

xen/common/domain.c +0 -0
index 30c227967345..ab16124eabd6 100644
@@ -671,6 +671,8 @@ struct domain *domain_create(domid_t domid,
 
Quoted 9 lines

xen/common/domain.c struct domain *domain_create(domid_t domid, · line 677

Quoted 6 lines
xen/common/domain.c +2 -0
       if ( !is_idle_domain(d) )
       {
+        ASSERT(config);
+
           watchdog_domain_init(d);
           init_status |= INIT_watchdog;

Just to mention it: Even if right now it turned out to help, it wouldn't once release builds are also checked.

Indeed. I thought about it when writing the e-mail yesterday. I have the feeling that we are not getting many similar report today thanks to the various ASSERT().

This may mean that the ASSERT() will have to be kept during static analysis or we deviate/add proper error checking.

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw
Quoted 23 lines · Julien Grall

Hi Jan,

Quoted 10 lines · Jan Beulich
Quoted 9 lines · Julien Grall

Instead, it would be best to find a way to help Eclair to detect this is not an issue and also improve readability. Would the following help Eclair?

xen/common/domain.c +0 -0
index 30c227967345..ab16124eabd6 100644
@@ -671,6 +671,8 @@ struct domain *domain_create(domid_t domid,
 
Quoted 9 lines

xen/common/domain.c struct domain *domain_create(domid_t domid, · line 677

Quoted 6 lines
xen/common/domain.c +2 -0
       if ( !is_idle_domain(d) )
       {
+        ASSERT(config);
+
           watchdog_domain_init(d);
           init_status |= INIT_watchdog;

Just to mention it: Even if right now it turned out to help, it wouldn't once release builds are also checked.

Quoted 8 lines

Indeed. I thought about it when writing the e-mail yesterday. I have the feeling that we are not getting many similar report today thanks to the various ASSERT().

This may mean that the ASSERT() will have to be kept during static analysis or we deviate/add proper error checking.

Cheers,

I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to decide how do you want to proceed: my suggestion is deviating it, and then when someone has the time to fix this with proper error handling remove the deviation.

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#12 lore raw

Hi Nicola,

Quoted 3 lines · Nicola Vetrini

On 17/10/2023 15:28, Julien Grall wrote:
I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to decide how do you want to proceed: my suggestion is deviating it,

It is not clear to me what would you deviate. Can you clarify?

Cheers,

Signature · 1 line
Julien Grall
#13 lore raw
Quoted 10 lines · Julien Grall

Hi Nicola,

Quoted 3 lines · Nicola Vetrini

On 17/10/2023 15:28, Julien Grall wrote:
I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to decide how do you want to proceed: my suggestion is deviating it,

It is not clear to me what would you deviate. Can you clarify?

Cheers,

The memcpy call, as in:

/* SAF-x-false-positive-eclair */ memcpy(d->handle, config->handle, sizeof(d->handle));

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#14 lore raw

Hi,

Quoted 8 lines · Nicola Vetrini
Quoted 7 lines · Julien Grall

Hi Nicola,

Quoted 3 lines · Nicola Vetrini

On 17/10/2023 15:28, Julien Grall wrote:
I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to decide how do you want to proceed: my suggestion is deviating it,

Quoted 8 lines
Quoted 3 lines

It is not clear to me what would you deviate. Can you clarify?

Cheers,

The memcpy call, as in:

/* SAF-x-false-positive-eclair */ memcpy(d->handle, config->handle, sizeof(d->handle));

I am not in favor of this deviation. It could be a false positive today, but it may not be in the future.

I much prefer the ASSERT() version or the rework.

Cheers,

Signature · 1 line
Julien Grall
#15 lore raw
Quoted 16 lines · Julien Grall
Quoted 15 lines · Nicola Vetrini
Quoted 11 lines · Julien Grall

Hi Nicola,

Quoted 4 lines · Nicola Vetrini

On 17/10/2023 15:28, Julien Grall wrote:
I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to
decide how do you want to proceed: my suggestion is deviating it,

It is not clear to me what would you deviate. Can you clarify?

Cheers,

The memcpy call, as in:

Quoted 7 lines
Quoted 2 lines

/* SAF-x-false-positive-eclair */ memcpy(d->handle, config->handle, sizeof(d->handle));

I am not in favor of this deviation. It could be a false positive today, but it may not be in the future.

I much prefer the ASSERT() version or the rework.

Just to be clear about the next steps, Nicola are you OK with sending a patch with the ASSERT or would you prefer Julien or someone else to do it?

#16 lore raw
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Julien Grall
Quoted 17 lines · Nicola Vetrini
Quoted 11 lines · Julien Grall

Hi Nicola,

Quoted 4 lines · Nicola Vetrini

On 17/10/2023 15:28, Julien Grall wrote:
I tested this, and the report is prevented by the ASSERT. It's up to the maintainers to
decide how do you want to proceed: my suggestion is deviating it,

It is not clear to me what would you deviate. Can you clarify?

Cheers,

The memcpy call, as in:

/* SAF-x-false-positive-eclair */ memcpy(d->handle, config->handle, sizeof(d->handle));

Quoted 8 lines
Quoted 4 lines

I am not in favor of this deviation. It could be a false positive today, but it may not be in the future.

I much prefer the ASSERT() version or the rework.

Just to be clear about the next steps, Nicola are you OK with sending a patch with the ASSERT or would you prefer Julien or someone else to do it?

Anyone can pick this up.

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)