qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net: check packet payload length
@ 2016-02-17 12:08 P J P
  2016-02-17 12:57 ` Markus Armbruster
  0 siblings, 1 reply; 10+ messages in thread
From: P J P @ 2016-02-17 12:08 UTC (permalink / raw)
  To: Qemu Developers; +Cc: Jason Wang, Prasad J Pandit, Liu Ling

From: Prasad J Pandit <pjp@fedoraproject.org>

While computing IP checksum, 'net_checksum_calculate' reads
payload length from the packet. It could exceed the given 'data'
buffer size. Add a check to avoid it.

Reported-by: Liu Ling <liuling-it@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 net/checksum.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/checksum.c b/net/checksum.c
index 14c0855..e51698c 100644
--- a/net/checksum.c
+++ b/net/checksum.c
@@ -76,8 +76,9 @@ void net_checksum_calculate(uint8_t *data, int length)
 	return;
     }
 
-    if (plen < csum_offset+2)
-	return;
+    if ((plen < csum_offset + 2) || (plen + hlen >= length)) {
+        return;
+    }
 
     data[14+hlen+csum_offset]   = 0;
     data[14+hlen+csum_offset+1] = 0;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-02-24  4:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 12:08 [Qemu-devel] [PATCH] net: check packet payload length P J P
2016-02-17 12:57 ` Markus Armbruster
2016-02-17 18:50   ` P J P
2016-02-18  7:42     ` P J P
2016-02-18  9:31     ` Markus Armbruster
2016-02-18 10:33       ` P J P
2016-02-23  7:57         ` Jason Wang
2016-02-23 11:11           ` P J P
2016-02-24  3:03             ` Jason Wang
2016-02-24  4:37               ` P J P

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).