public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Krzysztof Kozlowski <krzk@kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, peter.griffin@linaro.org,
	andre.draszik@linaro.org, jyescas@google.com,
	kernel-team@android.com, stable@vger.kernel.org
Subject: Re: [PATCH v4 1/7] firmware: samsung: acpm: Fix cross-thread RX length corruption
Date: Tue, 5 May 2026 12:14:48 +0300	[thread overview]
Message-ID: <cc973c62-4e33-4055-8059-dfc454447d0e@linaro.org> (raw)
In-Reply-To: <8e5ad1bc-e404-4247-8a38-aa2a51df24bb@kernel.org>



On 5/4/26 9:36 PM, Krzysztof Kozlowski wrote:
> On 04/05/2026 12:15, 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@vger.kernel.org
>> Fixes: a88927b534ba ("firmware: add Exynos ACPM protocol driver")
>> Closes: https://sashiko.dev/#/patchset/20260420-acpm-tmu-v3-0-3dc8e93f0b26%40linaro.org [1]
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> 
> I think parallel credits for Titouan Ameline would be suitable here.

I agree.

> If there is going to be new version, please also add:

There's going to be a new version, will add. I have to admit I'm
impressed by sashiko's review skills.

Cheers,
ta


  reply	other threads:[~2026-05-05  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 10:15 [PATCH v4 0/7] firmware: samsung: acpm: Various fixes for sashiko bug reports Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 1/7] firmware: samsung: acpm: Fix cross-thread RX length corruption Tudor Ambarus
2026-05-04 18:36   ` Krzysztof Kozlowski
2026-05-05  9:14     ` Tudor Ambarus [this message]
2026-05-04 10:15 ` [PATCH v4 2/7] firmware: samsung: acpm: Fix mailbox channel leak on probe error Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 3/7] firmware: samsung: acpm: Fix dummy stubs to return ERR_PTR Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 4/7] firmware: samsung: acpm: Add memory barrier before advancing RX pointer Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 5/7] firmware: samsung: acpm: Fix false timeouts in polling path Tudor Ambarus
2026-05-05 12:14   ` Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 6/7] firmware: samsung: acpm: Fix missing LKMM barriers in RX and TX paths Tudor Ambarus
2026-05-04 10:15 ` [PATCH v4 7/7] firmware: samsung: acpm: Fix infinite loop on sequence number exhaustion Tudor Ambarus

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=cc973c62-4e33-4055-8059-dfc454447d0e@linaro.org \
    --to=tudor.ambarus@linaro.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andre.draszik@linaro.org \
    --cc=jyescas@google.com \
    --cc=kernel-team@android.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=stable@vger.kernel.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