Fixed integer overflow in e1000e
PATCH 1/1 Fixed integer overflow in e1000e
From: Andrew Melnychenko <[email protected]>
https://bugzilla.redhat.com/show_bug.cgi?id=1737400
Fixed setting max_queue_num if there are no peers in NICConf. qemu_new_nic() creates NICState with 1 NetClientState(index 0) without peers, set max_queue_num to 0 - It prevents undefined behavior and possible crashes, especially during pcie hotplug.
--- hw/net/e1000e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000e.c +1 -1
@@ -328,7 +328,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr) s->nic =qemu_new_nic (&net_e1000e_info, &s->conf,object_get_typename (OBJECT (s)), dev->id, s); - s->core.max_queue_num = s->conf.peers.queues -1 ; + s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues -1 :0 ;trace_e1000e_mac_set_permanent (MAC_ARG (macaddr));memcpy (s->core.permanent_mac, macaddr,sizeof (s->core.permanent_mac));
Signature · 1 line
2.24.1
Hi Andrew,
Please Cc all the maintainers:
./scripts/get_maintainer.pl -f hw/net/e1000e.c
Dmitry Fleytman <[email protected]> (maintainer:e1000e) Jason Wang <[email protected]> (odd fixer:Network devices) [email protected] (open list:All patches CC here)
Quoted 3 lines · On 3/3/20 7:29 PM, [email protected] wrote:
From: Andrew Melnychenko <[email protected]>
The BZ backtrace lists e1000e_tx_pkt_send() which you fixes, but you also fixes e1000e_start_recv(). Good.
Please include the BZ backtrace.
Quoted 2 lines
Fixed setting
max_queue_numif there are no peers in NICConf.qemu_new_nic()creates NICState with 1 NetClientState(index 0) without peers, setmax_queue_numto 0 - It prevents undefined behavior and possible crashes, especially during pcie hotplug.
Please add:
Quoted 19 lines
Signed-off-by Andrew Melnychenko <[email protected]>--- hw/net/e1000e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/e1000e.c +1
-1@@ -328,7 +328,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr) s->nic =qemu_new_nic (&net_e1000e_info, &s->conf,object_get_typename (OBJECT (s)), dev->id, s); - s->core.max_queue_num = s->conf.peers.queues -1 ; + s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues -1 :0 ;trace_e1000e_mac_set_permanent (MAC_ARG (macaddr));memcpy (s->core.permanent_mac, macaddr,sizeof (s->core.permanent_mac));