Skip to content

Commit 90a0778

Browse files
huthMichael Tokarev
authored andcommitted
hw/net/vmxnet3: Fix guest-triggerable assert()
The assert() that checks for valid MTU sizes can be triggered by the guest (e.g. with the reproducer code from the bug ticket https://gitlab.com/qemu-project/qemu/-/issues/517 ). Let's avoid this problem by simply logging the error and refusing to activate the device instead. Fixes: d05dcd9 ("net: vmxnet3: validate configuration values during activate") Signed-off-by: Thomas Huth <[email protected]> Cc: [email protected] Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Michael Tokarev <[email protected]> [Mjt: change format specifier from %d to %u for uint32_t argument]
1 parent 0084f68 commit 90a0778

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hw/net/vmxnet3.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,10 @@ static void vmxnet3_activate_device(VMXNET3State *s)
14391439
vmxnet3_setup_rx_filtering(s);
14401440
/* Cache fields from shared memory */
14411441
s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
1442-
assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu <= VMXNET3_MAX_MTU);
1442+
if (s->mtu < VMXNET3_MIN_MTU || s->mtu > VMXNET3_MAX_MTU) {
1443+
qemu_log_mask(LOG_GUEST_ERROR, "vmxnet3: Bad MTU size: %u\n", s->mtu);
1444+
return;
1445+
}
14431446
VMW_CFPRN("MTU is %u", s->mtu);
14441447

14451448
s->max_rx_frags =

0 commit comments

Comments
 (0)