From: Krzysztof Kozlowski <krzk@kernel.org>
To: Tudor Ambarus <tudor.ambarus@linaro.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 v2 4/6] firmware: samsung: acpm: Fix memory ordering race in RX path
Date: Tue, 28 Apr 2026 11:52:26 +0200 [thread overview]
Message-ID: <6bba950c-5527-4613-8c16-b52534bc75a5@kernel.org> (raw)
In-Reply-To: <20260427-acpm-fixes-sashiko-reports-v2-4-1ff8de94a997@linaro.org>
On 27/04/2026 17:04, Tudor Ambarus wrote:
> Sashiko identified a memory ordering race in RX path [1].
>
> When draining the RX queue or reading saved responses, the driver uses
> clear_bit() to release the sequence number back to the available pool.
> However, on weakly ordered architectures like ARM64, clear_bit() does
> not provide implicit memory barriers.
And it does not have to if entire access is synchronized by other locks.
You need to analyze also this and mention here path which is not
synchronized and uses these weakly ordered atomic operations.
>
> This allows the CPU to reorder instructions, making the cleared bit
> globally visible before the preceding memory operations (memcpy() or
> __ioread32_copy()) have completed. If a concurrent thread allocates the
> newly freed sequence number, it can execute acpm_prepare_xfer() and
> zero out the buffer via memset() while the RX thread is still actively
> reading from it, leading to silent data corruption.
>
> Fix this by replacing clear_bit() with clear_bit_unlock() across the
> RX path. This provides release semantics, guaranteeing that all prior
> memory reads and writes are fully completed and visible before the
> sequence number is marked as free.
Barriers should be paired and release is paired with acquire.
bitmap_seqnum() is used with test_bit() and a separate set_bit(), which
do not have acquire semantics, although in some calls it is within lock.
Problem is I guess acpm_dequeue_by_polling() which is called without any
locks.
This means that other thread won't see updated values.
I think you also need to investigate and fix that acquire path.
Best regards,
Krzysztof
next prev parent reply other threads:[~2026-04-28 9:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 15:04 [PATCH v2 0/6] firmware: samsung: acpm: Various fixes for sashiko bug reports Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 1/6] firmware: samsung: acpm: Fix cross-thread RX length corruption Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 2/6] firmware: samsung: acpm: Fix mailbox channel leak on probe error Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 3/6] firmware: samsung: acpm: Fix dummy stubs to return ERR_PTR Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 4/6] firmware: samsung: acpm: Fix memory ordering race in RX path Tudor Ambarus
2026-04-28 9:52 ` Krzysztof Kozlowski [this message]
2026-04-28 12:57 ` Tudor Ambarus
2026-04-29 11:05 ` Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 5/6] firmware: samsung: acpm: Fix out-of-bounds read and infinite loop " Tudor Ambarus
2026-04-28 13:04 ` Tudor Ambarus
2026-04-27 15:04 ` [PATCH v2 6/6] 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=6bba950c-5527-4613-8c16-b52534bc75a5@kernel.org \
--to=krzk@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=andre.draszik@linaro.org \
--cc=jyescas@google.com \
--cc=kernel-team@android.com \
--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 \
--cc=tudor.ambarus@linaro.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