Skip to contentSkip to conversation

xen/x86: Annotate deliberate fallthrough cases from XSA-154

PATCH In review Andrew Cooper 2 participants 3 messages Feb 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/x86: Annotate deliberate fallthrough cases from XSA-154

Coverity objects otherwise.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/mm.c | 5 +++++
 1 file changed, 5 insertions(+)
xen/arch/x86/mm.c +5 -0
index a05edc3..0bff7dd 100644
@@ -924,10 +924,15 @@ get_page_from_l1e(
             {
             case 0:
                 break;
+
             case 1:
                 if ( is_hardware_domain(l1e_owner) )
+                {
+                    /* Fallthrough. */
             case -1:
                     return 0;
+                }
+                /* Fallthrough. */
             default:
                 ASSERT_UNREACHABLE();
             }
Signature · 1 line
2.1.4
#1 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 18.02.16 at 13:26, <[email protected]> wrote:

Coverity objects otherwise.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/mm.c | 5 +++++
 1 file changed, 5 insertions(+)
xen/arch/x86/mm.c +0 -0
index a05edc3..0bff7dd 100644
@@ -924,10 +924,15 @@ get_page_from_l1e(
             {
             case 0:
                 break;

xen/arch/x86/mm.c get_page_from_l1e( · line 936

Quoted 10 lines
xen/arch/x86/mm.c +5 -0
+
             case 1:
                 if ( is_hardware_domain(l1e_owner) )
+                {
+                    /* Fallthrough. */
             case -1:
                     return 0;
+                }
+                /* Fallthrough. */
             default:

This second fall-through is actually a bug (luckily noticable only on debug builds).

I'll commit the patch suitably adjusted, albeit I have a hard time seeing how

            case 1:
                if ( is_hardware_domain(l1e_owner) )
            case -1:

cannot be seen as obviously deliberate. Or did Coverity perhaps only complain about the second, indeed buggy one?

Jan

#2 lore raw
Quoted 31 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 18.02.16 at 13:26, <[email protected]> wrote:

Coverity objects otherwise.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/mm.c | 5 +++++
 1 file changed, 5 insertions(+)
xen/arch/x86/mm.c +0 -0
index a05edc3..0bff7dd 100644
@@ -924,10 +924,15 @@ get_page_from_l1e(
             {
             case 0:
                 break;

xen/arch/x86/mm.c get_page_from_l1e( · line 936

Quoted 10 lines
xen/arch/x86/mm.c +5 -0
+
             case 1:
                 if ( is_hardware_domain(l1e_owner) )
+                {
+                    /* Fallthrough. */
             case -1:
                     return 0;
+                }
+                /* Fallthrough. */
             default:

This second fall-through is actually a bug (luckily noticable only on debug builds).

Quoted 8 lines

I'll commit the patch suitably adjusted, albeit I have a hard time seeing how

            case 1:
                if ( is_hardware_domain(l1e_owner) )
            case -1:

cannot be seen as obviously deliberate.

Many C programmers are not aware that it is even valid syntax.

The point of the MISSING_BREAK check is to second guess what the programmer has actually written.

Quoted 2 lines

Or did Coverity perhaps
only complain about the second, indeed buggy one?

It only complained about the first. The second is a misaligned unconditional return when considered in isolation.

~Andrew