From: sashiko-bot@kernel.org
To: "Gregor Herburger" <gregor.herburger@linutronix.de>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 05/12] nvmem: Add the Raspberry Pi OTP driver
Date: Tue, 10 Nov 2026 17:18:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-207459@kernel.org> (raw)
In-Reply-To: <20261110-rpi-otp-driver-v8-5-797e0577d414@linutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] nvmem: raspberrypi-otp: fortify panic in rpi_otp_read() on
short count
--
commit c10d09bc13f73c4dd03231f9da5b8e776da5b958
Author: Gregor Herburger <gregor.herburger@linutronix.de>
nvmem: Add the Raspberry Pi OTP driver
This commit adds an nvmem driver to access the Raspberry Pi customer and
private OTP registers through the VideoCore firmware interface.
> diff --git a/drivers/nvmem/raspberrypi-otp.c b/drivers/nvmem/raspberrypi-otp.c
> new file mode 100644
> index 0000000000000..2e2537ee6793b
> --- /dev/null
> +++ b/drivers/nvmem/raspberrypi-otp.c
> @@ -0,0 +1,131 @@
[ ... ]
> +struct rpi_otp_header {
> + __le32 start;
> + __le32 count;
> + __le32 data[] __counted_by_le(count);
> +};
> +
> +static int rpi_otp_read(void *context, unsigned int offset, void *buf, size_t bytes)
> +{
> + struct rpi_otp_priv *priv = context;
> + struct rpi_otp_header *fwbuf;
> + u32 count;
> + int ret;
> +
> + count = bytes / 4;
> +
> + fwbuf = kzalloc(struct_size(fwbuf, data, count), GFP_KERNEL);
> + if (!fwbuf)
> + return -ENOMEM;
> +
> + fwbuf->start = cpu_to_le32(offset / 4);
> + fwbuf->count = cpu_to_le32(count);
> +
> + ret = rpi_firmware_property(priv->fw, priv->read_tag, fwbuf,
> + sizeof(struct rpi_otp_header) + bytes);
> + if (ret)
> + goto out;
> +
> + memcpy(buf, fwbuf->data, bytes);
[Severity: High]
Can this memcpy() trigger a fortify panic if the firmware response modifies
fwbuf->count?
rpi_firmware_property() overwrites the entire fwbuf buffer, including
fwbuf->count, with the response from the firmware. Because fwbuf->data[]
is annotated with __counted_by_le(count), CONFIG_FORTIFY_SOURCE evaluates
the runtime size of fwbuf->data from the returned fwbuf->count value, so
if the firmware zeroes or reduces fwbuf->count on a partial or unsupported
read, memcpy(buf, fwbuf->data, bytes) will call fortify_panic().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110-rpi-otp-driver-v8-0-797e0577d414@linutronix.de?part=5
next prev parent reply other threads:[~2026-11-10 17:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 16:33 [PATCH v8 00/12] nvmem: Add Raspberry Pi OTP nvmem driver Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 01/12] firmware: raspberrypi: reorder rpi_firmware_property_tag enum Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 02/12] soc: bcm2835: Use IS_REACHABLE for function declaration Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 03/12] nvmem: core: Enforce stride and alignment checks for nvmem_device functions Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 04/12] dt-bindings: raspberrypi,bcm2835-firmware: Add bcm2712-firmware compatible Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 05/12] nvmem: Add the Raspberry Pi OTP driver Gregor Herburger
2026-11-10 17:18 ` sashiko-bot [this message]
2026-11-10 16:34 ` [PATCH v8 06/12] firmware: raspberrypi: register nvmem driver Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 07/12] arm64: dts: broadcom: bcm2712: add raspberrypi,bcm2712-firmware compatible Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 08/12] dt-bindings: raspberrypi,bcm2835-firmware: Drop unnecessary select Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 09/12] arm64: defconfig: Enable the raspberrypi otp driver as module Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 10/12] ARM: bcm2835_defconfig: " Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 11/12] ARM: multi_v7_defconfig: " Gregor Herburger
2026-11-10 16:34 ` [PATCH v8 12/12] firmware: raspberrypi: use drvdata to register rtc driver Gregor Herburger
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=sashiko-outbox-207459@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregor.herburger@linutronix.de \
--cc=robh@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