From: sashiko-bot@kernel.org
To: "John Garry" <john.g.garry@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v4 02/28] libmultipath: Add basic gendisk support
Date: Thu, 23 Jul 2026 09:57:43 +0000 [thread overview]
Message-ID: <20260723095745.A90D21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723093627.2327456-3-john.g.garry@oracle.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] mpath_alloc_head_disk() leaves an ERR_PTR in mpath_head->disk on allocation failure, causing a kernel panic during cleanup.
- [High] mpath_head_init() fails to initialize multiple work items (remove_work, requeue_work), leading to kernel warnings and crashes.
- [High] The mpath_ops block_device_operations struct lacks a .submit_bio callback, causing device_add_disk() to fail unconditionally.
- [High] mpath_head_uninit() uses a synchronous wait for userspace file descriptors to close, deadlocking kernel unplug paths.
- [Medium] mpath_put_disk() claims to clean up pending bios but fails to schedule or flush requeue_work, leaking bios.
--
--- Patch [2]: [PATCH v4 02/28] libmultipath: Add basic gendisk support ---
commit 8b695b95ebd074db05fc7130622e9ffd48786c4d
Author: John Garry <john.g.garry@oracle.com>
libmultipath: Add basic gendisk support
This patch adds support to allocate and free a multipath gendisk. It
introduces the mpath_head_template to provide custom multipath functionality.
NVMe-like functions are added to manage multipath structures.
> diff --git a/lib/multipath.c b/lib/multipath.c
> index 9cc398d266adf..916d01a285284 100644
> --- a/lib/multipath.c
> +++ b/lib/multipath.c
> @@ -35,6 +35,102 @@ void mpath_head_uninit(struct mpath_head *mpath_head)
> }
> EXPORT_SYMBOL_GPL(mpath_head_uninit);
[Severity: High]
Does mpath_head_uninit() use a synchronous wait for userspace file
descriptors to close?
It appears this function contains:
wait_var_event(&mpath_head->refcount,
refcount_read(&mpath_head->refcount) == 1);
If userspace holds the block device open (for example via udev or
monitoring tools), this regression might block the kernel thread executing
the device removal forever in TASK_UNINTERRUPTIBLE, leading to a deadlock.
[ ... ]
> +const struct block_device_operations mpath_ops = {
> + .owner = THIS_MODULE,
> + .open = mpath_bdev_open,
> + .release = mpath_bdev_release,
> +};
[Severity: High]
Is it intentional to omit the .submit_bio callback here?
When mpath_device_set_live() is called, it triggers device_add_disk(),
which uses the block layer's __add_disk() function. This function verifies
that bio-based disks have a valid ->submit_bio pointer.
Since it is missing, this regression might unconditionally fail with
-EINVAL, preventing the multipath disk from being added to the system.
[ ... ]
> +void mpath_put_disk(struct mpath_head *mpath_head)
> +{
> + if (!mpath_head->disk)
> + return;
> +
> + /* make sure all pending bios are cleaned up */
> + flush_work(&mpath_head->partition_scan_work);
> + put_disk(mpath_head->disk);
> +}
[Severity: Medium]
Will pending bios actually be cleaned up without flushing requeue_work?
The comment indicates pending bios are handled, but drivers using the
requeue functionality might have bios stranded in mpath_head->requeue_list
unless mpath_head->requeue_work is also scheduled and flushed here.
[ ... ]
> +int mpath_alloc_head_disk(struct mpath_head *mpath_head,
> + struct queue_limits *lim, int numa_node)
> +{
> + if (!mpath_head->disk_groups || !mpath_head->parent)
> + return -EINVAL;
> +
> + mpath_head->disk = blk_alloc_disk(lim, numa_node);
> + if (IS_ERR(mpath_head->disk))
> + return PTR_ERR(mpath_head->disk);
[Severity: High]
Can this assignment leave an error pointer in mpath_head->disk on failure?
If blk_alloc_disk() fails, it returns an error pointer which is stored here
and not cleared before returning. Later, when standard teardown paths call
mpath_put_disk():
void mpath_put_disk(struct mpath_head *mpath_head)
{
if (!mpath_head->disk)
return;
The check will fail to catch the error pointer, which is then passed to
put_disk(). Could this regression result in a kernel panic when dereferenced?
[ ... ]
> +int mpath_head_init(struct mpath_head *mpath_head)
> +{
> + memset(mpath_head, 0, sizeof(*mpath_head));
> + mutex_init(&mpath_head->lock);
> + refcount_set(&mpath_head->refcount, 1);
> +
> + INIT_WORK(&mpath_head->partition_scan_work,
> + multipath_partition_scan_work);
[Severity: High]
Are there missing work initializations in this function?
While partition_scan_work is initialized, remove_work and requeue_work
from the mpath_head structure appear to be omitted.
When mpath_add_device() is called, it executes:
cancel_delayed_work(&mpath_head->remove_work)
Passing an uninitialized, zero-filled delayed_work structure into the
workqueue APIs can violate their contracts. Could this regression trigger
debug warnings or crashes in timer management code?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723093627.2327456-1-john.g.garry@oracle.com?part=2
next prev parent reply other threads:[~2026-07-23 9:57 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 9:35 [PATCH v4 00/28] Native SCSI Multipath support John Garry
2026-07-23 9:35 ` [PATCH v4 01/28] libmultipath: Add initial framework John Garry
2026-07-23 9:50 ` sashiko-bot
2026-07-23 10:19 ` John Garry
2026-07-23 9:36 ` [PATCH v4 02/28] libmultipath: Add basic gendisk support John Garry
2026-07-23 9:57 ` sashiko-bot [this message]
2026-07-23 10:34 ` John Garry
2026-07-23 9:36 ` [PATCH v4 03/28] libmultipath: Add path selection support John Garry
2026-07-23 9:55 ` sashiko-bot
2026-07-23 10:28 ` John Garry
2026-07-23 9:36 ` [PATCH v4 04/28] libmultipath: Add bio handling John Garry
2026-07-23 9:36 ` [PATCH v4 05/28] libmultipath: Add support for mpath_device management John Garry
2026-07-23 9:58 ` sashiko-bot
2026-07-23 10:36 ` John Garry
2026-07-23 9:36 ` [PATCH v4 06/28] libmultipath: Add delayed removal support John Garry
2026-07-23 9:57 ` sashiko-bot
2026-07-23 10:33 ` John Garry
2026-07-23 9:36 ` [PATCH v4 07/28] libmultipath: Add sysfs helpers John Garry
2026-07-23 10:05 ` sashiko-bot
2026-07-23 10:37 ` John Garry
2026-07-23 9:36 ` [PATCH v4 08/28] libmultipath: Add mpath_bdev_report_zones() John Garry
2026-07-23 10:15 ` sashiko-bot
2026-07-23 10:39 ` John Garry
2026-07-23 9:36 ` [PATCH v4 09/28] libmultipath: Add support for block device IOCTL John Garry
2026-07-23 10:09 ` sashiko-bot
2026-07-23 10:38 ` John Garry
2026-07-23 9:36 ` [PATCH v4 10/28] libmultipath: Add mpath_bdev_getgeo() John Garry
2026-07-23 9:36 ` [PATCH v4 11/28] libmultipath: Add mpath_bdev_get_unique_id() John Garry
2026-07-23 9:36 ` [PATCH v4 12/28] scsi-multipath: introduce basic SCSI device support John Garry
2026-07-23 10:14 ` sashiko-bot
2026-07-23 9:36 ` [PATCH v4 13/28] scsi-multipath: introduce scsi_device head structure John Garry
2026-07-23 10:16 ` sashiko-bot
2026-07-23 10:47 ` John Garry
2026-07-23 9:36 ` [PATCH v4 14/28] scsi-multipath: provide sysfs link from to scsi_device John Garry
2026-07-23 9:36 ` [PATCH v4 15/28] scsi-multipath: support iopolicy John Garry
2026-07-23 10:20 ` sashiko-bot
2026-07-23 10:51 ` John Garry
2026-07-23 9:36 ` [PATCH v4 16/28] scsi-multipath: clone each bio John Garry
2026-07-23 10:27 ` sashiko-bot
2026-07-23 10:55 ` John Garry
2026-07-23 9:36 ` [PATCH v4 17/28] scsi-multipath: clear path when device is blocked John Garry
2026-07-23 10:33 ` sashiko-bot
2026-07-23 11:01 ` John Garry
2026-07-23 9:36 ` [PATCH v4 18/28] scsi-multipath: revalidate paths upon device unblock John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:15 ` John Garry
2026-07-23 9:36 ` [PATCH v4 19/28] scsi-multipath: failover handling John Garry
2026-07-23 10:36 ` sashiko-bot
2026-07-23 11:03 ` John Garry
2026-07-23 9:36 ` [PATCH v4 20/28] scsi-multipath: provide callbacks for path state John Garry
2026-07-23 10:36 ` sashiko-bot
2026-07-23 11:05 ` John Garry
2026-07-23 9:36 ` [PATCH v4 21/28] scsi-multipath: add scsi_mpath_{start,end}_request() John Garry
2026-07-23 10:32 ` sashiko-bot
2026-07-23 10:57 ` John Garry
2026-07-23 9:36 ` [PATCH v4 22/28] scsi-multipath: add delayed disk removal support John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:21 ` John Garry
2026-07-23 9:36 ` [PATCH v4 23/28] scsi: sd: add multipath disk class John Garry
2026-07-23 10:39 ` sashiko-bot
2026-07-23 11:21 ` John Garry
2026-07-23 9:36 ` [PATCH v4 24/28] scsi: sd: add multipath disk attr groups John Garry
2026-07-23 10:47 ` sashiko-bot
2026-07-23 11:22 ` John Garry
2026-07-23 9:36 ` [PATCH v4 25/28] scsi: sd: support multipath disk John Garry
2026-07-23 10:47 ` sashiko-bot
2026-07-23 11:27 ` John Garry
2026-07-23 16:52 ` John Garry
2026-07-23 9:36 ` [PATCH v4 26/28] scsi: sd: add mpath_dev file John Garry
2026-07-23 11:07 ` sashiko-bot
2026-07-23 11:30 ` John Garry
2026-07-23 9:36 ` [PATCH v4 27/28] scsi: sd: add mpath_numa_nodes dev attribute John Garry
2026-07-23 10:52 ` sashiko-bot
2026-07-23 11:30 ` John Garry
2026-07-23 9:36 ` [PATCH v4 28/28] scsi: sd: add mpath_queue_depth " 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=20260723095745.A90D21F000E9@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 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.