From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>,
pratyush@kernel.org, mwalle@kernel.org,
takahiro.kuwano@infineon.com, miquel.raynal@bootlin.com,
richard@nod.at, vigneshr@ti.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, srini@kernel.org,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, linux@armlinux.org.uk,
richardcochran@gmail.com, linusw@kernel.org, arnd@arndb.de,
pengpeng@iscas.ac.cn, gregkh@linuxfoundation.org,
mathieu.dubois-briand@bootlin.com, michael@walle.cc,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v9 5/8] nvmem: layouts: add Microchip/SST SFDP EUI layout driver
Date: Sat, 17 Oct 2026 10:40:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-175471@kernel.org> (raw)
In-Reply-To: <9d578cf2d4ded92eb0b78a5e131e86fa19022b34.1792145382.git.manikandan.m@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] nvmem: Use-after-free on layout module unload via read_post_process
--
commit 38845f9d622725238fc32b8e1eac3c9b7dc8b3b7
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 (e.g. SST26VF064BEUI)
as a "mac-address" cell, for use as a network MAC address.
> diff --git a/drivers/nvmem/layouts/sst26vf-sfdp-eui.c b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
> new file mode 100644
> index 0000000000000..f46a6d9d0e93a
> --- /dev/null
> +++ b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
[ ... ]
> +static int sfdp_eui_add_cells(struct nvmem_layout *layout)
> +{
> + struct nvmem_device *nvmem = layout->nvmem;
[ ... ]
> + info.name = "mac-address";
> + info.offset = base + SFDP_MCHP_EUI48_OFFSET;
> + info.bytes = ETH_ALEN;
> + info.np = of_get_child_by_name(layout_np, "mac-address");
> + info.read_post_process = sfdp_eui_read_post_process;
> +
> + ret = nvmem_add_one_cell(nvmem, &info);
> + if (ret)
> + of_node_put(info.np);
> +
> + of_node_put(layout_np);
> +
> + return ret;
> +}
[ ... ]
> +static void sfdp_eui_remove(struct nvmem_layout *layout)
> +{
> + nvmem_layout_unregister(layout);
> +}
[Severity: High]
Does this code leave the module vulnerable to a use-after-free panic on
module unload?
The core nvmem function nvmem_layout_unregister() is an empty stub that does
not remove the registered cells:
drivers/nvmem/core.c:nvmem_layout_unregister() {
/* Keep the API even with an empty stub in case we need it later */
}
When this layout driver is unloaded, sfdp_eui_remove() calls
nvmem_layout_unregister(layout) but the cells and sysfs attributes are left
dangling.
Because the cell was configured with a read_post_process callback pointing to
sfdp_eui_read_post_process in this module's text segment, a subsequent read of
the sysfs cell file after the module is unloaded will call the dangling
function pointer:
drivers/nvmem/core.c:__nvmem_cell_read() {
...
rc = cell->read_post_process(cell->priv, id, index,
cell->offset, buf, cell->raw_len);
...
}
Will this cause a kernel panic by executing freed module memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792145382.git.manikandan.m@microchip.com?part=5
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>,
pratyush@kernel.org, mwalle@kernel.org,
takahiro.kuwano@infineon.com, miquel.raynal@bootlin.com,
richard@nod.at, vigneshr@ti.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, srini@kernel.org,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, linux@armlinux.org.uk,
richardcochran@gmail.com, linusw@kernel.org, arnd@arndb.de,
pengpeng@iscas.ac.cn, gregkh@linuxfoundation.org,
mathieu.dubois-briand@bootlin.com, michael@walle.cc,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v9 5/8] nvmem: layouts: add Microchip/SST SFDP EUI layout driver
Date: Sat, 17 Oct 2026 10:40:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-175471@kernel.org> (raw)
In-Reply-To: <9d578cf2d4ded92eb0b78a5e131e86fa19022b34.1792145382.git.manikandan.m@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] nvmem: Use-after-free on layout module unload via read_post_process
--
commit 38845f9d622725238fc32b8e1eac3c9b7dc8b3b7
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 (e.g. SST26VF064BEUI)
as a "mac-address" cell, for use as a network MAC address.
> diff --git a/drivers/nvmem/layouts/sst26vf-sfdp-eui.c b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
> new file mode 100644
> index 0000000000000..f46a6d9d0e93a
> --- /dev/null
> +++ b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c
[ ... ]
> +static int sfdp_eui_add_cells(struct nvmem_layout *layout)
> +{
> + struct nvmem_device *nvmem = layout->nvmem;
[ ... ]
> + info.name = "mac-address";
> + info.offset = base + SFDP_MCHP_EUI48_OFFSET;
> + info.bytes = ETH_ALEN;
> + info.np = of_get_child_by_name(layout_np, "mac-address");
> + info.read_post_process = sfdp_eui_read_post_process;
> +
> + ret = nvmem_add_one_cell(nvmem, &info);
> + if (ret)
> + of_node_put(info.np);
> +
> + of_node_put(layout_np);
> +
> + return ret;
> +}
[ ... ]
> +static void sfdp_eui_remove(struct nvmem_layout *layout)
> +{
> + nvmem_layout_unregister(layout);
> +}
[Severity: High]
Does this code leave the module vulnerable to a use-after-free panic on
module unload?
The core nvmem function nvmem_layout_unregister() is an empty stub that does
not remove the registered cells:
drivers/nvmem/core.c:nvmem_layout_unregister() {
/* Keep the API even with an empty stub in case we need it later */
}
When this layout driver is unloaded, sfdp_eui_remove() calls
nvmem_layout_unregister(layout) but the cells and sysfs attributes are left
dangling.
Because the cell was configured with a read_post_process callback pointing to
sfdp_eui_read_post_process in this module's text segment, a subsequent read of
the sysfs cell file after the module is unloaded will call the dangling
function pointer:
drivers/nvmem/core.c:__nvmem_cell_read() {
...
rc = cell->read_post_process(cell->priv, id, index,
cell->offset, buf, cell->raw_len);
...
}
Will this cause a kernel panic by executing freed module memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792145382.git.manikandan.m@microchip.com?part=5
next prev parent reply other threads:[~2026-10-17 10:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 10:38 [PATCH v9 0/8] Read MAC address from SST vendor specific SFDP region Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-16 10:38 ` [PATCH v9 1/8] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-16 10:38 ` [PATCH v9 2/8] dt-bindings: nvmem: layouts: add Microchip/SST SFDP EUI layout Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-16 10:38 ` [PATCH v9 3/8] nvmem: core: take a reference on dev.of_node in nvmem_register() Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-16 10:38 ` [PATCH v9 4/8] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-17 10:40 ` sashiko-bot
2026-10-17 10:40 ` sashiko-bot
2026-10-16 10:38 ` [PATCH v9 5/8] nvmem: layouts: add Microchip/SST SFDP EUI layout driver Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-17 10:40 ` sashiko-bot [this message]
2026-10-17 10:40 ` sashiko-bot
2026-10-16 10:38 ` [PATCH v9 6/8] ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI flash Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-16 10:38 ` [PATCH v9 7/8] ARM: dts: microchip: sama5d27_wlsom1: read MAC address from QSPI SFDP Manikandan Muralidharan
2026-10-16 10:38 ` Manikandan Muralidharan
2026-10-17 10:40 ` sashiko-bot
2026-10-17 10:40 ` sashiko-bot
2026-10-16 10:38 ` [PATCH v9 8/8] ARM: configs: sama5: enable Microchip/SST SFDP EUI NVMEM layout Manikandan Muralidharan
2026-10-16 10:38 ` 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=sashiko-outbox-175471@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=manikandan.m@microchip.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pengpeng@iscas.ac.cn \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=srini@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.