mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
To: Lee Jones <lee@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Etienne Carriere <etienne.carriere@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Srinivas Kandagatla <srini@kernel.org>
Subject: Re: [PATCH 10/10] nvmem: stm32: Avoid OP-TEE session leak on unaligned writes
Date: Thu, 3 Dec 2026 11:16:21 +0100	[thread overview]
Message-ID: <d1cef501-5eda-4b9a-b14b-3bcc3183fb97@foss.st.com> (raw)
In-Reply-To: <f53e9d28b35c2d6d6564d651a87074e602aa7223.1796286324.git.lee@kernel.org>

Hi,

On 12/3/26 09:26, Lee Jones wrote:
> stm32_bsec_optee_ta_write() opens a TEE session via
> stm32_bsec_ta_open_session() before validating that offset and bytes
> are 4-byte aligned.  Because the parent NVMEM device registers with
> word_size and stride set to 1, an unaligned write reaches this function
> and returns -EINVAL directly without closing the opened TEE session.
>
> Validate offset and bytes alignment before opening the OP-TEE session.
>
> Fixes: 6a0bc3522e74 ("nvmem: stm32: add OP-TEE support for STM32MP13x")
> Closes: https://sashiko.dev/#/bug/linux-b95e4408-6d2d-4b55-a422-f96cba011647
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Etienne Carriere <etienne.carriere@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Srinivas Kandagatla <srini@kernel.org>
>
>   drivers/nvmem/stm32-bsec-optee-ta.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/nvmem/stm32-bsec-optee-ta.c b/drivers/nvmem/stm32-bsec-optee-ta.c
> index f89ce791dd12..7ffeaa4258a1 100644
> --- a/drivers/nvmem/stm32-bsec-optee-ta.c
> +++ b/drivers/nvmem/stm32-bsec-optee-ta.c
> @@ -211,14 +211,14 @@ int stm32_bsec_optee_ta_write(struct tee_context *ctx, unsigned int lower,
>   	int ret;
>   	u32 session_id;
>   
> -	ret = stm32_bsec_ta_open_session(ctx, &session_id);
> -	if (ret)
> -		return ret;
> -
>   	/* Allow only writing complete 32-bits aligned words */
>   	if ((bytes % 4) || (offset % 4))
>   		return -EINVAL;
>   
> +	ret = stm32_bsec_ta_open_session(ctx, &session_id);
> +	if (ret)
> +		return ret;
> +
>   	memset(&arg, 0, sizeof(arg));
>   	memset(&param, 0, sizeof(param));
>   


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>


Thanks
Patrick


      reply	other threads:[~2026-12-03 10:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  8:26 [PATCH 00/10] nvmem: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03  8:26 ` [PATCH 01/10] nvmem: meson-efuse: Reject negative or zero SMC size in meson_efuse_probe() Lee Jones
2026-12-03  8:26 ` [PATCH 02/10] nvmem: core: Prevent integer underflow in nvmem_cell_attr_read() Lee Jones
2026-12-03  8:26 ` [PATCH 03/10] nvmem: sprd: Avoid out-of-bounds read on partial writes in sprd_efuse_raw_prog() Lee Jones
2026-12-03  8:26 ` [PATCH 04/10] nvmem: core: Handle multi-byte bit offsets in nvmem_cell_prepare_write_buffer() Lee Jones
2026-12-03  8:26 ` [PATCH 05/10] nvmem: core: Serialise writes when toggling the write-protect GPIO Lee Jones
2026-12-03  8:26 ` [PATCH 06/10] nvmem: eeprom_93xx46: Reject unaligned writes on 16-bit devices Lee Jones
2026-12-03  8:26 ` [PATCH 07/10] nvmem: eeprom_93xx46: Hold device lock across erase/write enable sequences Lee Jones
2026-12-03  8:26 ` [PATCH 08/10] nvmem: eeprom_93xx46: Use DMA-safe command buffer for SPI transfers Lee Jones
2026-12-03  8:26 ` [PATCH 09/10] nvmem: meson-efuse: Detect short reads and writes from Secure Monitor Lee Jones
2026-12-03  8:26 ` [PATCH 10/10] nvmem: stm32: Avoid OP-TEE session leak on unaligned writes Lee Jones
2026-12-03 10:16   ` Patrick DELAUNAY [this message]

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=d1cef501-5eda-4b9a-b14b-3bcc3183fb97@foss.st.com \
    --to=patrick.delaunay@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=etienne.carriere@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=srini@kernel.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

all inboxes | Powered by JetHome®