Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>
Cc: "Vignesh Raghavendra" <vigneshr@ti.com>,
	"Pratyush Yadav" <pratyush@kernel.org>,
	"Richard Weinberger" <richard@nod.at>,
	devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
	"Michael Walle" <mwalle@kernel.org>,
	"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>
Subject: Re: [PATCH v6 4/7] nvmem: layouts: add Microchip/SST SFDP EUI layout driver
Date: Thu, 30 Jul 2026 04:32:02 +0000	[thread overview]
Message-ID: <20260730043203.87C7F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729043026.1811147-5-manikandan.m@microchip.com>

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

Pre-existing issues:
- [High] Module unload leads to a Use-After-Free (UAF) due to a dangling `read_post_process` callback because NVMEM layout cells are not dynamically unregistered.
--

--- Patch [4]: [PATCH v6 4/7] nvmem: layouts: add Microchip/SST SFDP EUI layout driver ---
commit 16c236b381f7d2d9225ab89076bcd39b341f60db
Author: Manikandan Muralidharan <manikandan.m@microchip.com>

nvmem: layouts: add Microchip/SST SFDP EUI layout driver

Add an NVMEM layout that exposes the factory-programmed EUI-48 identifier
from the Microchip/SST vendor SFDP parameter table as a mac-address cell.

> diff --git a/drivers/nvmem/layouts/sst26vf-sfdp-eui.c b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
> new file mode 100644
> index 0000000000000..641318d6f0af6
> --- /dev/null
> +++ b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
[ ... ]
> +static void sfdp_eui_remove(struct nvmem_layout *layout)
> +{
> +	nvmem_layout_unregister(layout);
> +}

[Severity: High]
This isn't a bug introduced by this patch, but it exposes a pre-existing
architectural flaw in the NVMEM core.

Since this driver can be built as a module, what happens when it is unloaded?

Looking at the NVMEM core, nvmem_layout_unregister() is an empty stub. It
does not actually unregister the cells or remove their sysfs interfaces.

If a user reads the NVMEM cell via sysfs after this module is unloaded, the
core calls __nvmem_cell_read(), which dereferences the now-dangling
sfdp_eui_read_post_process callback pointer, resulting in a use-after-free.

Should this driver be restricted to a built-in driver until the NVMEM core
properly implements layout unregistration?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729043026.1811147-1-manikandan.m@microchip.com?part=4

  reply	other threads:[~2026-07-30  4:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  4:30 [PATCH v6 0/7] Read MAC address from SST vendor specific SFDP region Manikandan Muralidharan
2026-07-29  4:30 ` [PATCH v6 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM Manikandan Muralidharan
2026-07-29  4:30 ` [PATCH v6 2/7] dt-bindings: nvmem: layouts: add Microchip/SST SFDP EUI layout Manikandan Muralidharan
2026-07-29  4:30 ` [PATCH v6 3/7] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device Manikandan Muralidharan
2026-07-29  8:01   ` Michael Walle
2026-07-29  9:08     ` Manikandan.M
2026-07-29  4:30 ` [PATCH v6 4/7] nvmem: layouts: add Microchip/SST SFDP EUI layout driver Manikandan Muralidharan
2026-07-30  4:32   ` sashiko-bot [this message]
2026-07-29  4:30 ` [PATCH v6 5/7] ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI flash Manikandan Muralidharan
2026-07-29  4:30 ` [PATCH v6 6/7] ARM: dts: microchip: sama5d27_wlsom1: read MAC address from QSPI SFDP Manikandan Muralidharan
2026-07-30  4:32   ` sashiko-bot
2026-07-30  7:31     ` Manikandan.M
2026-07-29  4:30 ` [PATCH v6 7/7] ARM: configs: sama5: enable Microchip/SST SFDP EUI NVMEM layout Manikandan Muralidharan

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=20260730043203.87C7F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=manikandan.m@microchip.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=takahiro.kuwano@infineon.com \
    --cc=vigneshr@ti.com \
    /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