From: Jim MacArthur <jim.macarthur@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 4/9] hw/dma/omap_dma: Be more careful about overflow in transfer setup
Date: Tue, 14 Jul 2026 16:50:39 +0100 [thread overview]
Message-ID: <alZaz6DQe4oMCvDn@linaro.org> (raw)
In-Reply-To: <20260710105907.2570621-5-peter.maydell@linaro.org>
On Fri, Jul 10, 2026 at 11:59:02AM +0100, Peter Maydell wrote:
> In omap_dma_transfer_setup(), the maximum number of elements we can
> transfer is 0xffff * 0xffff == 0xfffe0001 (because the max frame
> count and max elements per frame are both 65535). However, we store
> total element counts in 'int' variables, and use INT_MAX as a "bigger
> than any valid value" sentinel, and when performing arithmetic with
> the total count of transferred elements we are not careful about
> avoiding overflows. Fix these:
>
> - use uint32_t rather than int for the local variables tracking
> various element and frame counts
> - use UINT_MAX as our sentinel
> - calculate new packet, element and frame counter values using
> arithmetic on a local uint32_t, rather than doing it in-place
> on local variables that are only 'int' because the actual
> counter registers are 16 bits
> - use 64-bit arithmetic when calculating how much to advance the
> source and dest pointers and the total dma->bytes transferred
>
> Note that since soc_dma_ch_s::bytes is only 'int' this can still
> overflow; we'll fix that in a subsequent patch.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
LGTM, thanks Peter.
Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>
next prev parent reply other threads:[~2026-07-14 15:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 10:58 [PATCH 0/9] omap_dma: avoid non-bounds-checked memcopy Peter Maydell
2026-07-10 10:58 ` [PATCH 1/9] hw/dma/soc_dma: Remove soc_dma_port_fifo support Peter Maydell
2026-07-13 10:57 ` Philippe Mathieu-Daudé
2026-07-10 10:59 ` [PATCH 2/9] hw/dma/soc_dma: Simplify soc_dma_ch_update() Peter Maydell
2026-07-20 10:10 ` Alex Bennée
2026-07-10 10:59 ` [PATCH 3/9] hw/dma/soc_dma: Remove union from memmap_entry_s struct Peter Maydell
2026-07-13 10:56 ` Philippe Mathieu-Daudé
2026-07-10 10:59 ` [PATCH 4/9] hw/dma/omap_dma: Be more careful about overflow in transfer setup Peter Maydell
2026-07-14 15:50 ` Jim MacArthur [this message]
2026-07-10 10:59 ` [PATCH 5/9] hw/dma/soc_dma: dma bytes is uint64_t Peter Maydell
2026-07-14 15:56 ` Jim MacArthur
2026-07-10 10:59 ` [PATCH 6/9] hw/dma/soc_dma: Use physical_memory_map() for mem2mem transfers Peter Maydell
2026-07-13 11:00 ` Philippe Mathieu-Daudé
2026-07-10 10:59 ` [PATCH 7/9] hw/dma/soc_dma: Remove unused mem.base, paddr fields Peter Maydell
2026-07-13 11:02 ` Philippe Mathieu-Daudé
2026-07-10 10:59 ` [PATCH 8/9] include/hw/arm/omap_dma.h: Move to include/hw/dma Peter Maydell
2026-07-10 13:37 ` Philippe Mathieu-Daudé
2026-07-10 13:49 ` Peter Maydell
2026-07-10 10:59 ` [PATCH 9/9] MAINTAINERS: Add soc_dma to OMAP section Peter Maydell
2026-07-13 12:12 ` Philippe Mathieu-Daudé
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=alZaz6DQe4oMCvDn@linaro.org \
--to=jim.macarthur@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@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 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.