|
|
9ae3a8 |
From fa1aaeeab2f10d7f107dd45a2c06e40e71bde1c3 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: "wexu@redhat.com" <wexu@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 21 Dec 2016 06:04:24 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 3/4] net: check packet payload length
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: wexu@redhat.com
|
|
|
9ae3a8 |
Message-id: <1482300264-29708-2-git-send-email-wexu@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 73088
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4/7.3.z qemu-kvm Patch v2] net: check packet payload length
|
|
|
9ae3a8 |
Bugzilla: 1398218
|
|
|
9ae3a8 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
While computing IP checksum, 'net_checksum_calculate' reads
|
|
|
9ae3a8 |
payload length from the packet. It could exceed the given 'data'
|
|
|
9ae3a8 |
buffer size. Add a check to avoid it.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This patch is to fix CVE-2016-2857.
|
|
|
9ae3a8 |
https://access.redhat.com/security/cve/CVE-2016-2857
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Liu Ling <liuling-it@360.cn>
|
|
|
9ae3a8 |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
9ae3a8 |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 362786f14a753d8a5256ef97d7c10ed576d6572b)
|
|
|
9ae3a8 |
Signed-off-by: Wei Xu <wexu@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
net/checksum.c | 10 ++++++++--
|
|
|
9ae3a8 |
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/net/checksum.c b/net/checksum.c
|
|
|
9ae3a8 |
index 14c0855..0942437 100644
|
|
|
9ae3a8 |
--- a/net/checksum.c
|
|
|
9ae3a8 |
+++ b/net/checksum.c
|
|
|
9ae3a8 |
@@ -59,6 +59,11 @@ void net_checksum_calculate(uint8_t *data, int length)
|
|
|
9ae3a8 |
int hlen, plen, proto, csum_offset;
|
|
|
9ae3a8 |
uint16_t csum;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* Ensure data has complete L2 & L3 headers. */
|
|
|
9ae3a8 |
+ if (length < 14 + 20) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
if ((data[14] & 0xf0) != 0x40)
|
|
|
9ae3a8 |
return; /* not IPv4 */
|
|
|
9ae3a8 |
hlen = (data[14] & 0x0f) * 4;
|
|
|
9ae3a8 |
@@ -76,8 +81,9 @@ void net_checksum_calculate(uint8_t *data, int length)
|
|
|
9ae3a8 |
return;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (plen < csum_offset+2)
|
|
|
9ae3a8 |
- return;
|
|
|
9ae3a8 |
+ if (plen < csum_offset + 2 || 14 + hlen + plen > length) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
data[14+hlen+csum_offset] = 0;
|
|
|
9ae3a8 |
data[14+hlen+csum_offset+1] = 0;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|