* [PATCH] scsi: 53c700: fix invalid frees in m68k driver remove paths
@ 2026-11-22 16:04 Ziheng Wei
2026-11-22 16:14 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-11-22 16:04 UTC (permalink / raw)
To: James E . J . Bottomley, Martin K . Petersen
Cc: linux-scsi, linux-m68k, linux-kernel, stable
NCR_700_detect() stores the allocated host parameters in
host->hostdata[0]. The m68k remove paths instead use shost_priv(host),
which returns the address of the pointer slot and causes an interior free.
Free the pointer stored in host->hostdata[0], as the other 53c700 drivers
do.
Found by LLM-assisted static analysis. Cross-compiled for m68k; no
runtime test on the affected hardware.
Fixes: a16efc1cbf0a ("[SCSI] 53c700: Amiga 4000T NCR53c710 SCSI")
Fixes: 8276b58af4dd ("[SCSI] 53c700: m68k BVME6000 NCR53C710 SCSI")
Fixes: 506c7bbcd9bc ("[SCSI] 53c700: m68k MVME16x NCR53C710 SCSI")
Fixes: 45804fbb00ee ("[SCSI] 53c700: Amiga Zorro NCR53c710 SCSI")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
drivers/scsi/a4000t.c | 3 ++-
drivers/scsi/bvme6000_scsi.c | 3 ++-
drivers/scsi/mvme16x_scsi.c | 3 ++-
drivers/scsi/zorro7xx.c | 3 ++-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c
index a02638b47..e35df140a 100644
--- a/drivers/scsi/a4000t.c
+++ b/drivers/scsi/a4000t.c
@@ -97,7 +97,8 @@ static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev)
static void __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
{
struct Scsi_Host *host = platform_get_drvdata(pdev);
- struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
+ struct NCR_700_Host_Parameters *hostdata =
+ (struct NCR_700_Host_Parameters *)host->hostdata[0];
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
scsi_remove_host(host);
diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
index 23301edf1..4054f788d 100644
--- a/drivers/scsi/bvme6000_scsi.c
+++ b/drivers/scsi/bvme6000_scsi.c
@@ -93,7 +93,8 @@ static void
bvme6000_device_remove(struct platform_device *dev)
{
struct Scsi_Host *host = platform_get_drvdata(dev);
- struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
+ struct NCR_700_Host_Parameters *hostdata =
+ (struct NCR_700_Host_Parameters *)host->hostdata[0];
scsi_remove_host(host);
NCR_700_release(host);
diff --git a/drivers/scsi/mvme16x_scsi.c b/drivers/scsi/mvme16x_scsi.c
index f4db93c13..ba458c1a5 100644
--- a/drivers/scsi/mvme16x_scsi.c
+++ b/drivers/scsi/mvme16x_scsi.c
@@ -106,7 +106,8 @@ static int mvme16x_probe(struct platform_device *dev)
static void mvme16x_device_remove(struct platform_device *dev)
{
struct Scsi_Host *host = platform_get_drvdata(dev);
- struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
+ struct NCR_700_Host_Parameters *hostdata =
+ (struct NCR_700_Host_Parameters *)host->hostdata[0];
/* Disable scsi chip ints */
{
diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c
index 894756326..6ec60deb7 100644
--- a/drivers/scsi/zorro7xx.c
+++ b/drivers/scsi/zorro7xx.c
@@ -161,7 +161,8 @@ static int zorro7xx_init_one(struct zorro_dev *z,
static void zorro7xx_remove_one(struct zorro_dev *z)
{
struct Scsi_Host *host = zorro_get_drvdata(z);
- struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
+ struct NCR_700_Host_Parameters *hostdata =
+ (struct NCR_700_Host_Parameters *)host->hostdata[0];
scsi_remove_host(host);
base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: 53c700: fix invalid frees in m68k driver remove paths
2026-11-22 16:04 [PATCH] scsi: 53c700: fix invalid frees in m68k driver remove paths Ziheng Wei
@ 2026-11-22 16:14 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-22 16:14 UTC (permalink / raw)
To: Ziheng Wei; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] scsi: bvme6000: sysfs use-after-free and DMA leak in
bvme6000_probe() [1]
--
commit 2fe2668801f69445d6459a951360087fb2a1f6f8
Author: Ziheng Wei <zihengw03@163.com>
scsi: 53c700: fix invalid frees in m68k driver remove paths
This commit retrieves hostdata from host->hostdata[0] instead of
shost_priv(host) in the m68k 53c700 driver remove callbacks so kfree()
frees the NCR_700_Host_Parameters allocation rather than an interior
pointer.
[ ... ]
> diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
> index 23301edf100d9..4054f788d1617 100644
> --- a/drivers/scsi/bvme6000_scsi.c
> +++ b/drivers/scsi/bvme6000_scsi.c
> @@ -93,7 +93,8 @@ static void
> bvme6000_device_remove(struct platform_device *dev)
> {
> struct Scsi_Host *host = platform_get_drvdata(dev);
> - struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
> + struct NCR_700_Host_Parameters *hostdata =
> + (struct NCR_700_Host_Parameters *)host->hostdata[0];
>
> scsi_remove_host(host);
> NCR_700_release(host);
[Severity: Critical]
This problem wasn't introduced by this patch, but in bvme6000_probe()
[1], does the request_irq() failure path leave host registered in
sysfs and leak the script DMA memory?
drivers/scsi/bvme6000_scsi.c:bvme6000_probe() {
...
host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
&dev->dev);
...
if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
host)) {
printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
goto out_put_host;
}
...
out_put_host:
scsi_host_put(host);
out_free:
kfree(hostdata);
out:
return -ENODEV;
}
NCR_700_detect() allocates DMA memory for hostdata->script and registers
host via scsi_add_host(). Jumping to out_put_host without calling
scsi_remove_host(host) and NCR_700_release(host) leaks the DMA buffer and
leaves orphaned sysfs entries that can trigger a use-after-free after
hostdata is freed.
[1] https://sashiko.dev/#/bug/linux-a5cb5983-a660-49d3-a7cf-4b23466e8a59
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122160447.519889-1-zihengw03@163.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-22 16:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 16:04 [PATCH] scsi: 53c700: fix invalid frees in m68k driver remove paths Ziheng Wei
2026-11-22 16:14 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox