Skip to contentSkip to conversation

hw/net/vmxnet3: Remove g_assert_not_reached() when VMXNET3_REG_ICR is written

PATCH In review Qiang Liu 2 participants 4 messages Jun 23, 2021 – Jun 25, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Qiang Liu

author
#1 lore raw

PATCH 1/1 hw/net/vmxnet3: Remove g_assert_not_reached() when VMXNET3_REG_ICR is written

From: cyruscyliu <[email protected]>

A malicious guest user can write VMXNET3_REG_ICR to crash QEMU. This patch remove the g_aasert_not_reached() there and make the access pass.

Fixes 786fd2b0f87 ("VMXNET3 device implementation")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/309

---
 hw/net/vmxnet3.c | 7 -------
 1 file changed, 7 deletions(-)
hw/net/vmxnet3.c +0 -7
index eff299f629..a388918479 100644
@@ -1786,13 +1786,6 @@ vmxnet3_io_bar1_write(void *opaque,
         vmxnet3_set_variable_mac(s, val, s->temp_mac);
         break;
 
-    /* Interrupt Cause Register */
-    case VMXNET3_REG_ICR:
-        VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
-                  val, size);
-        g_assert_not_reached();
-        break;
-
     /* Event Cause Register */
     case VMXNET3_REG_ECR:
         VMW_CBPRN("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",

--
2.30.2

#2 lore raw
Quoted 10 lines · Qiang Liu

From: cyruscyliu <[email protected]>

A malicious guest user can write VMXNET3_REG_ICR to crash QEMU. This patch remove the g_aasert_not_reached() there and make the access pass.

Fixes 786fd2b0f87 ("VMXNET3 device implementation")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/309

Do we need to warn about the unimplemented register?

Thanks

Quoted 25 lines
---
  hw/net/vmxnet3.c | 7 -------
  1 file changed, 7 deletions(-)
hw/net/vmxnet3.c +0 -8
index eff299f629..a388918479 100644
@@ -1786,13 +1786,6 @@ vmxnet3_io_bar1_write(void *opaque,
          vmxnet3_set_variable_mac(s, val, s->temp_mac);
          break;
 
-    /* Interrupt Cause Register */
-    case VMXNET3_REG_ICR:
-        VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
-                  val, size);
-        g_assert_not_reached();
-        break;
-
      /* Event Cause Register */
      case VMXNET3_REG_ECR:
          VMW_CBPRN("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",
--

2.30.2

author
#3 lore raw

Hi,

Quoted 8 lines · Jason Wang
Quoted 5 lines · Qiang Liu

From: cyruscyliu <[email protected]>

A malicious guest user can write VMXNET3_REG_ICR to crash QEMU. This patch remove the g_aasert_not_reached() there and make the access pass.

Quoted 8 lines
Quoted 5 lines
Fixes 786fd2b0f87 ("VMXNET3 device implementation")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/309

Do we need to warn about the unimplemented register?

If we remove the case branch, it will go to the default branch which can warn users if
VMXNET_DEBUG_CB_ENABLED is defined, so there is no need to warn this unimplemented register. Am I right?

```
vmxnet3_io_bar1_write(...
    default:
        VMW_CBPRN("Unknown Write to BAR1 [%" PRIx64 "] = %" PRIx64 ", size %d",
                  addr, val, size);
        break;
```
Quoted 29 lines

Thanks

Quoted 25 lines
---
  hw/net/vmxnet3.c | 7 -------
  1 file changed, 7 deletions(-)
hw/net/vmxnet3.c +0 -8
index eff299f629..a388918479 100644
@@ -1786,13 +1786,6 @@ vmxnet3_io_bar1_write(void *opaque,
          vmxnet3_set_variable_mac(s, val, s->temp_mac);
          break;
 
-    /* Interrupt Cause Register */
-    case VMXNET3_REG_ICR:
-        VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
-                  val, size);
-        g_assert_not_reached();
-        break;
-
      /* Event Cause Register */
      case VMXNET3_REG_ECR:
          VMW_CBPRN("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",
--

2.30.2

#4 lore raw
Quoted 20 lines · Qiang Liu

Hi,

Quoted 7 lines · Jason Wang
Quoted 5 lines · Qiang Liu

From: cyruscyliu <[email protected]>

A malicious guest user can write VMXNET3_REG_ICR to crash QEMU. This patch remove the g_aasert_not_reached() there and make the access pass.

Quoted 7 lines
Quoted 5 lines
Fixes 786fd2b0f87 ("VMXNET3 device implementation")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/309

Do we need to warn about the unimplemented register?

If we remove the case branch, it will go to the default branch which can warn users if
VMXNET_DEBUG_CB_ENABLED is defined, so there is no need to warn this unimplemented register. Am I right?

Quoted 7 lines
```
vmxnet3_io_bar1_write(...
     default:
         VMW_CBPRN("Unknown Write to BAR1 [%" PRIx64 "] = %" PRIx64 ", size %d",
                   addr, val, size);
         break;
```

Right.

I've queued this patch.

Thanks

Quoted 28 lines
Quoted 28 lines

Thanks

Quoted 25 lines
---
   hw/net/vmxnet3.c | 7 -------
   1 file changed, 7 deletions(-)
hw/net/vmxnet3.c +0 -8
index eff299f629..a388918479 100644
@@ -1786,13 +1786,6 @@ vmxnet3_io_bar1_write(void *opaque,
           vmxnet3_set_variable_mac(s, val, s->temp_mac);
           break;
 
-    /* Interrupt Cause Register */
-    case VMXNET3_REG_ICR:
-        VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
-                  val, size);
-        g_assert_not_reached();
-        break;
-
       /* Event Cause Register */
       case VMXNET3_REG_ECR:
           VMW_CBPRN("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",
--

2.30.2