* [PATCH 00/10] nvmem: Fix Critical and High issues reported by Sashiko
@ 2026-12-03 8:26 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
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-03 8:26 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Alexandre Torgue, Anatolij Gustschin, Andrew Morton,
Baolin Wang, Bartosz Golaszewski, Carlo Caione, Chunyan Zhang,
Dan Carpenter, Dmitry Baryshkov, Etienne Carriere, Freeman Liu,
Greg Kroah-Hartman, Jerome Brunet, Joy Chakraborty, Kevin Hilman,
Khouloud Touil, Linus Walleij, linux-amlogic, linux-arm-kernel,
linux-stm32, Martin Blumenstingl, Maxime Coquelin, Maxime Ripard,
Miquel Raynal, Neil Armstrong, Orson Zhai, Patrick Delaunay,
Randy Dunlap, Srinivas Kandagatla
This series fixes 10 Critical and High issues across the NVMEM core and
drivers (Meson eFuse, Spreadtrum eFuse, 93xx46 EEPROM, and STM32 BSEC
OP-TEE TA), covering out-of-bounds reads, integer underflow, multi-byte
bit-offset corruption, WP GPIO and erase/write locking races, stack DMA
buffers, unchecked SMC sizes/short transfers, and an OP-TEE session leak.
These issues were reported by Sashiko.
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: Carlo Caione <carlo@endlessm.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Freeman Liu <freeman.liu@unisoc.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Joy Chakraborty <joychakr@google.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Khouloud Touil <ktouil@baylibre.com>
Cc: Linus Walleij <linusw@kernel.org>
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Orson Zhai <orsonzhai@gmail.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Srinivas Kandagatla <srini@kernel.org>
Lee Jones (10):
nvmem: meson-efuse: Reject negative or zero SMC size in
meson_efuse_probe()
nvmem: core: Prevent integer underflow in nvmem_cell_attr_read()
nvmem: sprd: Avoid out-of-bounds read on partial writes in
sprd_efuse_raw_prog()
nvmem: core: Handle multi-byte bit offsets in
nvmem_cell_prepare_write_buffer()
nvmem: core: Serialise writes when toggling the write-protect GPIO
nvmem: eeprom_93xx46: Reject unaligned writes on 16-bit devices
nvmem: eeprom_93xx46: Hold device lock across erase/write enable
sequences
nvmem: eeprom_93xx46: Use DMA-safe command buffer for SPI transfers
nvmem: meson-efuse: Detect short reads and writes from Secure Monitor
nvmem: stm32: Avoid OP-TEE session leak on unaligned writes
drivers/nvmem/core.c | 50 ++++++++++++-----
drivers/nvmem/eeprom_93xx46.c | 85 +++++++++++++++--------------
drivers/nvmem/internals.h | 2 +
drivers/nvmem/meson-efuse.c | 17 ++++--
drivers/nvmem/sprd-efuse.c | 13 ++++-
drivers/nvmem/stm32-bsec-optee-ta.c | 8 +--
6 files changed, 111 insertions(+), 64 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 01/10] nvmem: meson-efuse: Reject negative or zero SMC size in meson_efuse_probe()
2026-12-03 8:26 [PATCH 00/10] nvmem: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-12-03 8:26 ` 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
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-03 8:26 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Carlo Caione, Jerome Brunet, Kevin Hilman,
linux-amlogic, linux-arm-kernel, Martin Blumenstingl,
Neil Armstrong, Srinivas Kandagatla
meson_sm_call() writes the signed Secure Monitor return value into its
s32 output pointer and returns 0 whenever the command ID is valid.
meson_efuse_probe() passes an unsigned int pointer to meson_sm_call()
and only checks for a negative return value from meson_sm_call() itself.
If firmware returns a negative SMC error code (such as
SMCCC_RET_NOT_SUPPORTED), size wraps to a large unsigned value and is
assigned to econfig->size.
Change size to s32 and reject negative or zero values from
SM_EFUSE_USER_MAX with -EINVAL.
Fixes: ad855eae6caf ("nvmem: amlogic: Add Amlogic Meson EFUSE driver")
Closes: https://sashiko.dev/#/bug/linux-0667e60b-53c5-4a5a-b9b4-bb6f8d7eb500
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
Cc: Carlo Caione <carlo@endlessm.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Srinivas Kandagatla <srini@kernel.org>
drivers/nvmem/meson-efuse.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
index d7f9ac99a212..e8f384098be5 100644
--- a/drivers/nvmem/meson-efuse.c
+++ b/drivers/nvmem/meson-efuse.c
@@ -51,7 +51,7 @@ static int meson_efuse_probe(struct platform_device *pdev)
struct nvmem_device *nvmem;
struct nvmem_config *econfig;
struct clk *clk;
- unsigned int size;
+ s32 size;
struct device_node *sm_np __free(device_node) =
of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0);
@@ -68,7 +68,8 @@ static int meson_efuse_probe(struct platform_device *pdev)
if (IS_ERR(clk))
return dev_err_probe(dev, PTR_ERR(clk), "failed to get efuse gate");
- if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) {
+ if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0 ||
+ size <= 0) {
dev_err(dev, "failed to get max user");
return -EINVAL;
}
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 09/10] nvmem: meson-efuse: Detect short reads and writes from Secure Monitor
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 ` Lee Jones
2026-12-03 8:26 ` [PATCH 10/10] nvmem: stm32: Avoid OP-TEE session leak on unaligned writes Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-03 8:26 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Carlo Caione, Dan Carpenter,
Greg Kroah-Hartman, Jerome Brunet, Joy Chakraborty, Kevin Hilman,
linux-amlogic, linux-arm-kernel, Martin Blumenstingl,
Neil Armstrong, Srinivas Kandagatla
meson_efuse_read() and meson_efuse_write() treat any non-negative byte
count returned by meson_sm_call_read() or meson_sm_call_write() as
success and return 0, silently hiding partial reads or writes.
Return -EIO when meson_sm_call_write() reports a byte count other than
bytes, or when meson_sm_call_read() returns a non-zero byte count that
does not match bytes (preserving the 0 return convention documented by
meson_sm_call_read()).
Fixes: 7a0a6d0a7c80 ("nvmem: meson-efuse: Fix return value of nvmem callbacks")
Closes: https://sashiko.dev/#/bug/linux-990a1e10-e629-4b29-956e-2b2d39ac8f4a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
Cc: Carlo Caione <carlo@endlessm.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Joy Chakraborty <joychakr@google.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Srinivas Kandagatla <srini@kernel.org>
drivers/nvmem/meson-efuse.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
index e8f384098be5..383ee9281693 100644
--- a/drivers/nvmem/meson-efuse.c
+++ b/drivers/nvmem/meson-efuse.c
@@ -22,8 +22,12 @@ static int meson_efuse_read(void *context, unsigned int offset,
ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
bytes, 0, 0, 0);
+ if (ret < 0)
+ return ret;
+ if (ret && ret != bytes)
+ return -EIO;
- return ret < 0 ? ret : 0;
+ return 0;
}
static int meson_efuse_write(void *context, unsigned int offset,
@@ -34,8 +38,12 @@ static int meson_efuse_write(void *context, unsigned int offset,
ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
bytes, 0, 0, 0);
+ if (ret < 0)
+ return ret;
+ if (ret != bytes)
+ return -EIO;
- return ret < 0 ? ret : 0;
+ return 0;
}
static const struct of_device_id meson_efuse_match[] = {
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 10/10] nvmem: stm32: Avoid OP-TEE session leak on unaligned writes
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 09/10] nvmem: meson-efuse: Detect short reads and writes from Secure Monitor Lee Jones
@ 2026-12-03 8:26 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-03 8:26 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Alexandre Torgue, Etienne Carriere,
Greg Kroah-Hartman, linux-arm-kernel, linux-stm32,
Maxime Coquelin, Patrick Delaunay, Srinivas Kandagatla
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(¶m, 0, sizeof(param));
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox