From: P J P <ppandit@redhat.com>
To: Qemu developers <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Dmitry Fleytman <dmitry@daynix.com>,
Jason Wang <jasowang@redhat.com>, Li Qiang <liqiang6-s@360.cn>
Subject: [Qemu-devel] [PATCH v2] net: vmxnet: use g_new for pkt initialisation
Date: Tue, 16 Aug 2016 16:58:01 +0530 [thread overview]
Message-ID: <1471346881-16679-1-git-send-email-ppandit@redhat.com> (raw)
From: Li Qiang <liqiang6-s@360.cn>
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.
Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
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
diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
index 53dfaa2..20b2549 100644
--- a/hw/net/net_tx_pkt.c
+++ b/hw/net/net_tx_pkt.c
@@ -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;
--
2.5.5
next reply other threads:[~2016-08-16 11:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-16 11:28 P J P [this message]
2016-08-16 11:29 ` [Qemu-devel] [PATCH v2] net: vmxnet: use g_new for pkt initialisation Dmitry Fleytman
2016-08-18 4:03 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471346881-16679-1-git-send-email-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=dmitry@daynix.com \
--cc=jasowang@redhat.com \
--cc=liqiang6-s@360.cn \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).