[PATCH v5 1/7] firmware: samsung: acpm: Fix cross-thread RX length corruption
Alexey Klimov
alexey.klimov at linaro.org
Wed May 6 08:17:12 PDT 2026
On Tue May 5, 2026 at 2:12 PM BST, Tudor Ambarus wrote:
> Sashiko identified a cross-thread RX length corruption bug when
> reviewing the thermal addition to ACPM [1].
>
> When multiple threads concurrently send IPC requests, the ACPM polling
> mechanism can encounter responses belonging to other threads. To drain
> the queue, the driver saves these concurrent responses into an internal
> cache (`rx_data->cmd`) to be retrieved later by the owning thread.
>
> Previously, the driver incorrectly used `xfer->rxcnt` (the expected
> receive length of the *current* polling thread) when copying data for
> *other* threads into this cache. If the threads expected responses of
> different lengths, this resulted in buffer underflows (leading to reads
> of uninitialized memory) or potential buffer overflows.
>
> Fix this by replacing the boolean `response` flag in
> `struct acpm_rx_data` with `rxcnt`, caching the exact expected receive
> length for each specific transaction during transfer preparation. Use
> this cached length when saving concurrent responses.
>
> Consequently, ensure that `xfer->rxcnt` is explicitly zeroed in driver
> helpers (e.g., `acpm_dvfs_set_xfer`) for fire-and-forget messages to
> prevent uninitialized stack garbage from being interpreted as a massive
> expected receive length.
>
> Cc: stable at vger.kernel.org
> Fixes: a88927b534ba ("firmware: add Exynos ACPM protocol driver")
> Reported-by: Titouan Ameline <titouan.ameline at gmail.com>
As far as I can see, the name in this tag should be
Titouan Ameline de Cadeville.
> Closes: https://sashiko.dev/#/patchset/20260420-acpm-tmu-v3-0-3dc8e93f0b26%40linaro.org [1]
> Closes: https://lore.kernel.org/r/20260426210255.73674-1-titouan.ameline@gmail.com/
> Signed-off-by: Tudor Ambarus <tudor.ambarus at linaro.org>
> ---
> drivers/firmware/samsung/exynos-acpm-dvfs.c | 3 +++
> drivers/firmware/samsung/exynos-acpm.c | 15 ++++++++-------
> 2 files changed, 11 insertions(+), 7 deletions(-)
[..]
Best regards,
Alexey
More information about the linux-arm-kernel
mailing list