net: vmxnet: use g_new for pkt initialisation
PATCH v2 1/1 net: vmxnet: use g_new for pkt initialisation
From: Li Qiang <[email protected]>
When network transport abstraction layer initialises pkt, the maximum fragmentation count is not checked. This could lead to an integer overflow causing a NULL pointer dereference. Replace g_malloc() with g_new() to catch the multiplication overflow.
--- hw/net/net_tx_pkt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Update as per review:
-> https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02544.html
hw/net/net_tx_pkt.c +2 -3
@@ -65,10 +65,9 @@ void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, p->pci_dev = pci_dev; - p->vec =g_malloc ((sizeof *p->vec) * - (max_frags +NET_TX_PKT_PL_START_FRAG )); + p->vec = g_new(struct iovec, max_frags + NET_TX_PKT_PL_START_FRAG); - p->raw =g_malloc ((sizeof *p->raw) * max_frags); + p->raw = g_new(struct iovec, max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags;
Signature · 1 line
2.5.5
Quoted 38 lines · P J P
From: Li Qiang <[email protected]>
When network transport abstraction layer initialises pkt, the maximum fragmentation count is not checked. This could lead to an integer overflow causing a NULL pointer dereference. Replace
g_malloc()withg_new()to catch the multiplication overflow.Reported-by Li Qiang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>---
hw/net/net_tx_pkt.c| 5 ++---1 file changed, 2 insertions(+), 3 deletions(-)Update as per review:
-> https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02544.htmlhw/net/net_tx_pkt.c +2
-3@@ -65,10 +65,9 @@ void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, p->pci_dev = pci_dev; - p->vec =g_malloc ((sizeof *p->vec) * - (max_frags +NET_TX_PKT_PL_START_FRAG )); + p->vec = g_new(struct iovec, max_frags + NET_TX_PKT_PL_START_FRAG); - p->raw =g_malloc ((sizeof *p->raw) * max_frags); + p->raw = g_new(struct iovec, max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags;Signature · 1 line
2.5.5
Jason Wang
AppliedQuoted 32 lines · Dmitry Fleytman
Acked-by Dmitry Fleytman <[email protected]>Quoted 30 lines · P J P
From: Li Qiang <[email protected]>
When network transport abstraction layer initialises pkt, the maximum fragmentation count is not checked. This could lead to an integer overflow causing a NULL pointer dereference. Replace
g_malloc()withg_new()to catch the multiplication overflow.Reported-by Li Qiang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>---
hw/net/net_tx_pkt.c| 5 ++---1 file changed, 2 insertions(+), 3 deletions(-)Update as per review:
-> https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02544.htmlhw/net/net_tx_pkt.c +1
-2@@ -65,10 +65,9 @@ void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, p->pci_dev = pci_dev; - p->vec =g_malloc ((sizeof *p->vec) * - (max_frags +NET_TX_PKT_PL_START_FRAG )); + p->vec = g_new(struct iovec, max_frags + NET_TX_PKT_PL_START_FRAG);
Quoted 8 lines
Quoted 8 lines
hw/net/net_tx_pkt.c +1
-1- p->raw =g_malloc ((sizeof *p->raw) * max_frags); + p->raw = g_new(struct iovec, max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags;Signature · 1 line
2.5.5
Applied, thanks.