Linux RTC
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Link Mauve" <linkmauve@linkmauve.fr>
Cc: lee@kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org,
	mfd@lists.linux.dev, imx@lists.linux.dev, ojeda@kernel.org,
	Frank.Li@kernel.org, linux-sunxi@lists.linux.dev,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH 6/8] firmware: meson_sm: make reg_write callback take const void *
Date: Wed, 15 Jul 2026 18:06:37 +0000	[thread overview]
Message-ID: <20260715180638.0E0011F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260715175229.24672-7-linkmauve@linkmauve.fr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Concurrent calls to `meson_sm_call_write` or `meson_sm_call_read` will corrupt the shared IOMEM buffer.
--

--- Patch [6]: [PATCH 6/8] firmware: meson_sm: make reg_write callback take const void * ---
commit 05903fc223bec5b04f497c8b4bf66c4c6d90ebfe
Author: Link Mauve <linkmauve@linkmauve.fr>

firmware: meson_sm: make reg_write callback take const void *

This commit updates the meson_sm_call_write callback and its header
declaration to take a const void * buffer. This aligns with a previous
change to the nvmem_config API that switched from a mutable to an
immutable data pointer.

> diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c
> index ab9751a59b552..5d4da2e3c3a94 100644
> --- a/drivers/firmware/meson/meson_sm.c
> +++ b/drivers/firmware/meson/meson_sm.c
> @@ -196,7 +196,7 @@ EXPORT_SYMBOL(meson_sm_call_read);
>   *
>   * Return:	size of sent data on success, a negative value on error
>   */
> -int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer,
> +int meson_sm_call_write(struct meson_sm_firmware *fw, const void *buffer,
>  			unsigned int size, unsigned int cmd_index, u32 arg0,
>  			u32 arg1, u32 arg2, u32 arg3, u32 arg4)
>  {

[ ... ]

>  	memcpy(fw->sm_shmem_in_base, buffer, size);
>  
>  	if (meson_sm_call(fw, cmd_index, &written, arg0, arg1, arg2, arg3, arg4) < 0)
>  		return -EINVAL;

[Severity: High]
This isn't a bug introduced by this patch, but does this function need
locking to protect the shared IOMEM buffer?

It appears that concurrent calls to meson_sm_call_write() or
meson_sm_call_read() could corrupt the shared sm_shmem_in_base and
sm_shmem_out_base buffers. If multiple threads concurrently write or read
the nvmem sysfs files, they might overwrite each other's payloads before
the SMC executes, sending corrupted data to the Secure Monitor.

A similar pattern exists in meson_sm_call_read():

	if (buffer)
		memcpy(buffer, fw->sm_shmem_out_base, size);

Are there external locks that guarantee serialized access to these functions,
or should we be synchronizing these shared memory operations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715175229.24672-1-linkmauve@linkmauve.fr?part=6

  reply	other threads:[~2026-07-15 18:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 17:52 [PATCH 0/8] nvmem: make reg_write() take a const void * Link Mauve
2026-07-15 17:52 ` [PATCH 1/8] nvmem: core: " Link Mauve
2026-07-15 18:00   ` sashiko-bot
2026-07-15 18:58   ` Andy Shevchenko
2026-07-15 19:03     ` Link Mauve
2026-07-15 17:52 ` [PATCH 2/8] nvmem: make all reg_write callbacks take " Link Mauve
2026-07-15 18:08   ` sashiko-bot
2026-07-15 17:52 ` [PATCH 3/8] rtc: " Link Mauve
2026-07-15 18:01   ` sashiko-bot
2026-07-15 17:52 ` [PATCH 4/8] misc: " Link Mauve
2026-07-15 18:04   ` sashiko-bot
2026-07-15 17:52 ` [PATCH 5/8] iio: pressure: bmp280: make reg_write callback " Link Mauve
2026-07-15 18:03   ` sashiko-bot
2026-07-15 17:52 ` [PATCH 6/8] firmware: meson_sm: " Link Mauve
2026-07-15 18:06   ` sashiko-bot [this message]
2026-07-15 17:52 ` [PATCH 7/8] mfd: twl-core: " Link Mauve
2026-07-15 18:08   ` sashiko-bot
2026-07-15 17:52 ` [PATCH 8/8] media: ov2740: remove NULL reg_write callback Link Mauve
2026-07-15 18:07   ` sashiko-bot
2026-07-15 19:02 ` [PATCH 0/8] nvmem: make reg_write() take a const void * Andy Shevchenko
2026-07-15 19:09   ` Link Mauve
2026-07-15 20:09   ` Yury Norov

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=20260715180638.0E0011F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=imx@lists.linux.dev \
    --cc=lee@kernel.org \
    --cc=linkmauve@linkmauve.fr \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mfd@lists.linux.dev \
    --cc=neil.armstrong@linaro.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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