All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gonglei (Arei)" <arei.gonglei@huawei.com>
To: "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "mst@redhat.com" <mst@redhat.com>,
	"liqiang6-s@360.cn" <liqiang6-s@360.cn>,
	"qemu-stable@nongnu.org" <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] virtio-crypto: fix possible integer and heap overflow
Date: Mon, 9 Jan 2017 02:10:13 +0000	[thread overview]
Message-ID: <33183CC9F5247A488A2544077AF19020DA180404@DGGEMA505-MBX.china.huawei.com> (raw)
In-Reply-To: <1483426203-16196-1-git-send-email-arei.gonglei@huawei.com>

Hi Michael,

Ping...



Regards,
-Gonglei


> -----Original Message-----
> From: Gonglei (Arei)
> Sent: Tuesday, January 03, 2017 2:50 PM
> To: qemu-devel@nongnu.org
> Cc: mst@redhat.com; liqiang6-s@360.cn; Gonglei (Arei);
> qemu-stable@nongnu.org
> 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.
> 
> Cc: qemu-stable@nongnu.org
> Reported-by: Li Qiang <liqiang6-s@360.cn>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Tested-by: Li Qiang <liqiang6-s@360.cn>
> ---
>  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 978bb98..fc30bc3 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.8.3.1
> 

      reply	other threads:[~2017-01-09  2:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03  6:50 [Qemu-devel] [PATCH] virtio-crypto: fix possible integer and heap overflow Gonglei
2017-01-09  2:10 ` Gonglei (Arei) [this message]

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=33183CC9F5247A488A2544077AF19020DA180404@DGGEMA505-MBX.china.huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=liqiang6-s@360.cn \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.