From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Stefan Weil <sw@weilnetz.de>
Subject: [Qemu-devel] [PULL for-2.3 1/4] nvme: Fix unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
Date: Fri, 27 Mar 2015 10:20:45 +0000 [thread overview]
Message-ID: <1427451648-29128-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1427451648-29128-1-git-send-email-stefanha@redhat.com>
From: Stefan Weil <sw@weilnetz.de>
The shift operation on nlb gives a 32 bit result if no type cast is
applied. This bug was reported by Coverity.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Message-id: 1426348844-8793-1-git-send-email-sw@weilnetz.de
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/block/nvme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 0f3dfb9..1e07166 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -222,7 +222,7 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
- uint64_t data_size = nlb << data_shift;
+ uint64_t data_size = (uint64_t)nlb << data_shift;
uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
--
2.1.0
next prev parent reply other threads:[~2015-03-27 10:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 10:20 [Qemu-devel] [PULL for-2.3 0/4] Block patches Stefan Hajnoczi
2015-03-27 10:20 ` Stefan Hajnoczi [this message]
2015-03-27 10:20 ` [Qemu-devel] [PULL for-2.3 2/4] block: Fix unaligned zero write Stefan Hajnoczi
2015-03-27 10:20 ` [Qemu-devel] [PULL for-2.3 3/4] qemu-iotests: Test unaligned 4k " Stefan Hajnoczi
2015-03-27 10:20 ` [Qemu-devel] [PULL for-2.3 4/4] block: Document blockdev-add's immaturity Stefan Hajnoczi
2015-03-27 12:12 ` [Qemu-devel] [PULL for-2.3 0/4] Block patches Peter Maydell
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=1427451648-29128-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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).