All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: malike <malike@kylinos.cn>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, hreitz@redhat.com,
	qemu-block@nongnu.org
Subject: Re: [PATCH] block/cloop: fix integer overflow in total_sectors calculation
Date: Tue, 14 Jul 2026 12:31:14 +0200	[thread overview]
Message-ID: <alYP8ikcV9KHA7wB@redhat.com> (raw)
In-Reply-To: <20260713031750.58448-1-malike@kylinos.cn>

Am 13.07.2026 um 05:17 hat malike geschrieben:
> The total_sectors is computed as n_blocks * sectors_per_block where
> both operands are uint32_t. The multiplication is performed in 32-bit
> arithmetic and can overflow when the product exceeds UINT32_MAX,
> producing a value much smaller than the true image size. The result
> is assigned to int64_t total_sectors but the 32-bit multiplication
> has already wrapped around, and the zero-extension to 64-bit does
> not recover the correct value.
> 
> This causes the block layer to reject valid I/O requests (DoS) when
> the reported total_sectors is smaller than the actual image.
> 
> Use 64-bit arithmetic by casting one operand to uint64_t so the
> multiplication is performed in 64-bit precision.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3972
> Signed-off-by: Ma Like <malike@kylinos.cn>

Thanks, applied to the block branch.

Kevin



      reply	other threads:[~2026-07-14 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  3:17 [PATCH] block/cloop: fix integer overflow in total_sectors calculation malike
2026-07-14 10:31 ` Kevin Wolf [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=alYP8ikcV9KHA7wB@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=malike@kylinos.cn \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.