From 4c6acb2de2b9612dfae273e63348c40921ebf235 Mon Sep 17 00:00:00 2001 From: Sona Sarmadi Date: Thu, 14 Sep 2017 08:16:06 +0200 Subject: qemu: CVE-2017-5931 Fixes integer overflow in in handling virtio-crypto requests Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5931 Signed-off-by: Sona Sarmadi Signed-off-by: Martin Borg --- recipes-devtools/qemu/qemu/CVE-2017-5931.patch | 52 ++++++++++++++++++++++++++ recipes-devtools/qemu/qemu_%.bbappend | 1 + 2 files changed, 53 insertions(+) create mode 100644 recipes-devtools/qemu/qemu/CVE-2017-5931.patch diff --git a/recipes-devtools/qemu/qemu/CVE-2017-5931.patch b/recipes-devtools/qemu/qemu/CVE-2017-5931.patch new file mode 100644 index 0000000..4c35c26 --- /dev/null +++ b/recipes-devtools/qemu/qemu/CVE-2017-5931.patch @@ -0,0 +1,52 @@ +From d6f119475d3c9c913f9140771895036be66d5c33 Mon Sep 17 00:00:00 2001 +From: Gonglei +Date: Tue, 3 Jan 2017 14:50:03 +0800 +Subject: [PATCH] virtio-crypto: fix possible integer and heap overflow + +Because the 'size_t' type is 4 bytes in 32-bit platform, which +is the same with 'int'. It's easy to make 'max_len' to zero when +integer overflow and then cause heap overflow if 'max_len' is zero. + +Using uint_64 instead of size_t to avoid the integer overflow. + +CVE: CVE-2017-5931 +Upstream-Status: Backport [backport from 2.8.1.1 releases: https://git.qemu.org/?p=qemu.git;a=commit;h=d6f119475d3c9c913f9140771895036be66d5c33] + +Cc: qemu-stable@nongnu.org +Reported-by: Li Qiang +Signed-off-by: Gonglei +Tested-by: Li Qiang +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +(cherry picked from commit a08aaff811fb194950f79711d2afe5a892ae03a4) +Signed-off-by: Michael Roth +Signed-off-by: Sona Sarmadi +--- + hw/virtio/virtio-crypto.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c +index 2f2467e..c23e1ad 100644 +--- a/hw/virtio/virtio-crypto.c ++++ b/hw/virtio/virtio-crypto.c +@@ -416,7 +416,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, + uint32_t hash_start_src_offset = 0, len_to_hash = 0; + uint32_t cipher_start_src_offset = 0, len_to_cipher = 0; + +- size_t max_len, curr_size = 0; ++ uint64_t max_len, curr_size = 0; + size_t s; + + /* Plain cipher */ +@@ -441,7 +441,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, + return NULL; + } + +- max_len = iv_len + aad_len + src_len + dst_len + hash_result_len; ++ max_len = (uint64_t)iv_len + aad_len + src_len + dst_len + hash_result_len; + if (unlikely(max_len > vcrypto->conf.max_size)) { + virtio_error(vdev, "virtio-crypto too big length"); + return NULL; +-- +1.9.1 + diff --git a/recipes-devtools/qemu/qemu_%.bbappend b/recipes-devtools/qemu/qemu_%.bbappend index 3ebff2d..e27553c 100644 --- a/recipes-devtools/qemu/qemu_%.bbappend +++ b/recipes-devtools/qemu/qemu_%.bbappend @@ -6,4 +6,5 @@ SRC_URI += "file://0001-CVE-2017-2620.patch \ file://CVE-2017-7471.patch \ file://CVE-2017-6505.patch \ file://CVE-2017-8309.patch \ + file://CVE-2017-5931.patch \ " -- cgit v1.2.3-54-g00ecf