usb: fix up post load checks
PATCH v2 1/1 usb: fix up post load checks
Correct post load checks:
1. dev->setup_len == sizeof(dev->data_buf)
seems fine, no need to fail migration
2. When state is DATA, passing index > len
will cause memcpy with negative length,
resulting in heap overflow
First of the issues was reported by dgilbert.
Reported-by "Dr. David Alan Gilbert" <[email protected]>
Signed-off-by Michael S. Tsirkin <[email protected]>
---
changes from v1:
- drop state check
- lightly tested
hw/usb/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/bus.c +2 -2
@@ -51,8 +51,8 @@ static int usb_device_post_load(void *opaque, int version_id) }if (dev->setup_index <0 || dev->setup_len <0 || - dev->setup_index >=sizeof (dev->data_buf) || - dev->setup_len >=sizeof (dev->data_buf)) { + dev->setup_index > dev->setup_len || + dev->setup_len >sizeof (dev->data_buf)) {return -EINVAL ; }return 0 ;
Signature · 1 line
MST
Juan Quintela
AppliedQuoted 11 lines · Michael S. Tsirkin
Correct post load checks:
1.dev->setup_len==sizeof(dev->data_buf)
seems fine, no need to fail migration
2. When state is DATA, passing index > len
will cause memcpy with negative length,
resulting in heap overflowFirst of the issues was reported by dgilbert.
Reported-by "Dr. David Alan Gilbert" <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
Thanks, applied.