qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	Qemu-block <qemu-block@nongnu.org>
Subject: qemu-img.c possibly overflowing shifts by BDRV_SECTOR_BITS
Date: Tue, 9 Nov 2021 19:07:15 +0000	[thread overview]
Message-ID: <CAFEAcA_LUNY7NRt=vDeoHDgaeBYZTzVEx8i8Ce_KopE8Z4_WpQ@mail.gmail.com> (raw)

Hi; Coverity is complaining about some of the places in qemu-img.c
where it takes a 32-bit variable and shifts it left by BDRV_SECTOR_BITS
to convert a sector count to a byte count, because it's doing the
shift in 32-bits rather than 64 and so Coverity thinks there might
be overflow (CID 1465221, 1465219). Is it right and we need extra
casts to force the shift to be done in 64 bits, or is there some
constraint that means we know the sector counts are always small
enough that the byte count is 2GB or less ?

thanks
-- PMM


             reply	other threads:[~2021-11-09 19:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 19:07 Peter Maydell [this message]
2021-11-10 11:36 ` qemu-img.c possibly overflowing shifts by BDRV_SECTOR_BITS Kevin Wolf
2021-11-10 14:31   ` 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='CAFEAcA_LUNY7NRt=vDeoHDgaeBYZTzVEx8i8Ce_KopE8Z4_WpQ@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@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 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).