From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 5/7] zloop: add degrade_element control command
Date: Wed, 07 Oct 2026 08:39:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-162753@kernel.org> (raw)
In-Reply-To: <20261007082344.1049179-6-dlemoal@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] block: double-free and UAF in zloop_ctl_add error path
- [Low] block: missing presence check and error message for element_id in zloop_ctl_degrade_element
--
commit 85f6af597dc5c733cb0ab607eae7cb9cac0357b4
Author: Damien Le Moal <dlemoal@kernel.org>
zloop: add degrade_element control command
Allow users to mark storage elements of a zloop device as degraded using
the new "degrade_element" control command. The element to degrade is
indicated using the element_id option.
> diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
> index e113ecd63c0b2..311588de853fc 100644
> --- a/drivers/block/zloop.c
> +++ b/drivers/block/zloop.c
[ ... ]
> @@ -1384,6 +1890,8 @@ static int zloop_ctl_add(struct zloop_options *opts)
> kfree(zlo->base_dir);
> out_destroy_workqueue:
> destroy_workqueue(zlo->workqueue);
> +out_destroy_storage_elements:
> + kfree(zlo->elements);
[Severity: High]
Does this code introduce a double-free and use-after-free on zlo->elements?
When a failure in zloop_ctl_add() causes execution to jump to the
out_cleanup_disk label (which is located just above this block),
put_disk(zlo->disk) is called. This synchronously triggers the
zloop_free_disk() fops callback. This callback completely frees zlo and
its members, including zlo->elements.
The error path then falls through and accesses the already freed zlo pointer
to sequentially double-free the same resources, including the newly added
zlo->elements shown here.
Can this be triggered from user-space by writing invalid parameters or
encountering resource exhaustion during the device add command on
/dev/zloop-control?
[ ... ]
> @@ -1946,6 +1991,42 @@ static int zloop_ctl_remove(struct zloop_options *opts)
> return 0;
> }
>
> +static int zloop_ctl_degrade_element(struct zloop_options *opts)
> +{
> + struct zloop_device *zlo;
> + int ret = 0;
> +
> + if (!(opts->mask & ZLOOP_OPT_ID)) {
> + pr_err("No ID specified for degrade_element\n");
> + return -EINVAL;
> + }
> +
> + if (opts->mask & ~(ZLOOP_OPT_ID | ZLOOP_OPT_ELEMENT_ID)) {
> + pr_err("Invalid option specified for degrade_element\n");
> + return -EINVAL;
> + }
[Severity: Low]
Does this code fail to verify the presence of the ZLOOP_OPT_ELEMENT_ID option?
This bitwise check in zloop_ctl_degrade_element() only validates that no
extra options are present, but it does not enforce that ZLOOP_OPT_ELEMENT_ID
is actually provided. If element_id is omitted, it defaults to 0 and
zloop_degrade_element(zlo, 0) will safely catch this and return -EINVAL.
However, the user receives a silent failure rather than an informative error
message about the missing required argument.
Can we add a check similar to ZLOOP_OPT_ID to ensure ZLOOP_OPT_ELEMENT_ID
is explicitly provided?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261007082344.1049179-1-dlemoal@kernel.org?part=5
next prev parent reply other threads:[~2026-10-07 8:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 8:23 [PATCH v3 0/7] Add support for storage element depopulation Damien Le Moal
2026-10-07 8:23 ` [PATCH v3 1/7] block: fail reads to offline zones early Damien Le Moal
2026-10-07 8:41 ` sashiko-bot
2026-10-07 13:29 ` Christoph Hellwig
2026-10-07 14:31 ` Damien Le Moal
2026-10-07 8:23 ` [PATCH v3 2/7] block: introduce storage element management Damien Le Moal
2026-10-07 8:34 ` sashiko-bot
2026-10-07 13:35 ` Christoph Hellwig
2026-10-07 14:35 ` Damien Le Moal
2026-10-07 8:23 ` [PATCH v3 3/7] block: add storage element management ioctls Damien Le Moal
2026-10-07 8:39 ` sashiko-bot
2026-10-07 13:39 ` Christoph Hellwig
2026-10-07 14:37 ` Damien Le Moal
2026-10-07 15:28 ` Christoph Hellwig
2026-10-07 8:23 ` [PATCH v3 4/7] zloop: add storage element emulation Damien Le Moal
2026-10-07 8:35 ` sashiko-bot
2026-10-07 13:40 ` Christoph Hellwig
2026-10-07 8:23 ` [PATCH v3 5/7] zloop: add degrade_element control command Damien Le Moal
2026-10-07 8:39 ` sashiko-bot [this message]
2026-10-07 8:23 ` [PATCH v3 6/7] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-10-07 8:35 ` sashiko-bot
2026-10-07 8:23 ` [PATCH v3 7/7] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-10-07 8:40 ` sashiko-bot
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-162753@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dlemoal@kernel.org \
--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