From: sashiko-bot@kernel.org
To: "John Garry" <john.g.garry@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 10/17] scsi-multipath: block PR commands
Date: Fri, 03 Jul 2026 12:03:38 +0000 [thread overview]
Message-ID: <20260703120338.F35081F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703103402.3725011-11-john.g.garry@oracle.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Double-free and use-after-free of `scsi_mpath_head` and its resources on the `dev_set_name` failure path.
- [High] Calling `list_del_init` on an uninitialized list_head and `device_unregister` on a failed device addition.
--
commit 3be4a33456416864c9e49c5cfb76773fb5375009
Author: John Garry <john.g.garry@oracle.com>
scsi-multipath: block PR commands
For initial scsi-multipath support, do not support Persistent Reservations
(PRs). This change intercepts PR SCSI commands for passthrough and rejects
them since PR support for SCSI is quite complicated.
> diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c
> index 61fa2e4cdfdab..b4d9d6518b4fe 100644
> --- a/drivers/scsi/scsi_multipath.c
> +++ b/drivers/scsi/scsi_multipath.c
[ ... ]
While reviewing this file, I noticed a couple of pre-existing issues:
drivers/scsi/scsi_multipath.c:scsi_mpath_alloc_head() {
...
ret = dev_set_name(&scsi_mpath_head->dev, "scsi_mpath_device%d",
scsi_mpath_head->index);
if (ret) {
put_device(&scsi_mpath_head->dev);
goto out_free_ida;
}
...
}
[Severity: High]
This is a pre-existing issue, but can this lead to a double-free?
If dev_set_name() fails, the error path calls put_device(). Since
device_initialize() sets the kref count to 1, this drops the count to 0 and
immediately invokes the release function scsi_mpath_head_release().
The scsi_mpath_head_release() function will free the scsi_mpath_head memory
via kfree() as well as associated resources like the IDA and bioset.
The code then incorrectly falls through to out_free_ida, executing ida_free(),
mpath_put_head(), bioset_exit(), and a second kfree() on the already freed
scsi_mpath_head pointer. Will this result in a double-free and memory
corruption?
A similar issue appears in a different error path:
drivers/scsi/scsi_multipath.c:scsi_mpath_dev_alloc() {
...
ret = device_add(&scsi_mpath_head->dev);
if (ret) {
mutex_unlock(&scsi_mpath_heads_lock);
goto out_put_head;
}
...
}
Which eventually calls the release function:
drivers/scsi/scsi_multipath.c:scsi_mpath_free_head() {
...
list_del_init(&scsi_mpath_head->entry);
mutex_unlock(&scsi_mpath_heads_lock);
device_unregister(&scsi_mpath_head->dev);
...
}
[Severity: High]
This is a pre-existing issue, but does this release function operate on an
unlinked list head and a partially initialized device?
In scsi_mpath_dev_alloc(), if device_add() fails, it jumps to out_put_head and
calls scsi_mpath_put_head(). This drops the reference to 0 and invokes
scsi_mpath_free_head().
When scsi_mpath_free_head() calls list_del_init(&scsi_mpath_head->entry), the
entry is uninitialized (zeroed by kzalloc) because device_add() failed before
list_add_tail() was ever called. Can this result in a NULL pointer dereference
when __list_del_entry() attempts to link the pointers?
Furthermore, it then unconditionally calls device_unregister(). Does this
incorrectly attempt to device_del() a device that was never successfully added,
leading to driver core warnings or crashes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260703103402.3725011-1-john.g.garry@oracle.com?part=10
next prev parent reply other threads:[~2026-07-03 12:03 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:33 [PATCH v3 00/17] Native SCSI multipath support John Garry
2026-07-03 10:33 ` [PATCH v3 01/17] scsi-multipath: introduce basic SCSI device support John Garry
2026-07-03 10:53 ` sashiko-bot
2026-07-06 14:39 ` John Garry
2026-07-03 10:33 ` [PATCH v3 02/17] scsi-multipath: introduce scsi_device head structure John Garry
2026-07-03 10:49 ` sashiko-bot
2026-07-06 14:45 ` John Garry
2026-07-03 10:33 ` [PATCH v3 03/17] scsi-multipath: provide sysfs link from to scsi_device John Garry
2026-07-03 11:04 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 04/17] scsi-multipath: support iopolicy John Garry
2026-07-03 11:10 ` sashiko-bot
2026-07-06 14:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 05/17] scsi-multipath: clone each bio John Garry
2026-07-03 11:26 ` sashiko-bot
2026-07-06 14:53 ` John Garry
2026-07-03 10:33 ` [PATCH v3 06/17] scsi-multipath: clear path when device is blocked John Garry
2026-07-03 11:32 ` sashiko-bot
2026-07-06 15:04 ` John Garry
2026-07-03 10:33 ` [PATCH v3 07/17] scsi-multipath: failover handling John Garry
2026-07-03 11:40 ` sashiko-bot
2026-07-06 15:32 ` John Garry
2026-07-03 10:33 ` [PATCH v3 08/17] scsi-multipath: provide callbacks for path state John Garry
2026-07-03 11:49 ` sashiko-bot
2026-07-06 15:38 ` John Garry
2026-07-03 10:33 ` [PATCH v3 09/17] scsi-multipath: add scsi_mpath_{start,end}_request() John Garry
2026-07-03 11:53 ` sashiko-bot
2026-07-06 15:44 ` John Garry
2026-07-03 10:33 ` [PATCH v3 10/17] scsi-multipath: block PR commands John Garry
2026-07-03 12:03 ` sashiko-bot [this message]
2026-07-03 10:33 ` [PATCH v3 11/17] scsi-multipath: add delayed disk removal support John Garry
2026-07-03 12:08 ` sashiko-bot
2026-07-06 15:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 12/17] scsi: sd: add multipath disk class John Garry
2026-07-03 10:33 ` [PATCH v3 13/17] scsi: sd: support multipath disk John Garry
2026-07-03 12:24 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 14/17] scsi: sd: add multipath disk attr groups John Garry
2026-07-03 12:25 ` sashiko-bot
2026-07-03 10:34 ` [PATCH v3 15/17] scsi: sd: add mpath_dev file John Garry
2026-07-03 12:43 ` sashiko-bot
2026-07-06 15:56 ` John Garry
2026-07-03 10:34 ` [PATCH v3 16/17] scsi: sd: add mpath_numa_nodes dev attribute John Garry
2026-07-03 12:44 ` sashiko-bot
2026-07-06 15:57 ` John Garry
2026-07-03 10:34 ` [PATCH v3 17/17] scsi: sd: add mpath_queue_depth " John Garry
2026-07-03 12:57 ` sashiko-bot
2026-07-06 15:59 ` John Garry
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=20260703120338.F35081F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=linux-scsi@vger.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