From: no-reply@sashiko.virtuozzo.com
To: "Denis V. Lunev" <den@openvz.org>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 1/2] ms/blk-throttle: fix access race during throttle policy activation
Date: Mon, 2 Nov 2026 16:59:07 +0000 [thread overview]
Message-ID: <010701a19d334d83-a30b270a-30d0-4a81-9a2e-e83dd8547c05-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261102161219.3735623-2-den@openvz.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] blk-throttle: blk_throtl_exit() skips teardown and leaks td after bit cleared
--
commit b69e5d24a46730350dbae00100359769cb6cf354
Author: Han Guangjiang <hanguangjiang@lixiang.com>
ms/blk-throttle: fix access race during throttle policy activation
This backport tightens blk_throtl_activated() so that it also requires the
throttle policy bit to be set in q->blkcg_pols. The aim is to stop
blk_should_throtl() from dereferencing a NULL throtl_grp while the policy
is still being activated. It also moves blkcg_policy_enabled() into
blk-cgroup.h so blk-throttle.h can use it.
Link: https://virtuozzo.atlassian.net/browse/VSTOR-152993
> diff --git a/block/blk-throttle.h b/block/blk-throttle.h
> --- a/block/blk-throttle.h
> +++ b/block/blk-throttle.h
[ ... ]
> static inline bool blk_throtl_activated(struct request_queue *q)
> {
> - return q->td != NULL;
> + /*
> + * q->td guarantees that the blk-throttle module is already loaded,
> + * and the plid of blk-throttle is assigned.
> + * blkcg_policy_enabled() guarantees that the policy is activated
> + * in the request_queue.
> + */
> + return q->td != NULL && blkcg_policy_enabled(q, &blkcg_policy_throtl);
> }
[Severity: Medium]
Does this stricter predicate break blk_throtl_exit(), which also uses
blk_throtl_activated()?
The disk release path is:
blkcg_exit_disk()
blkg_destroy_all(disk);
blk_throtl_exit(disk);
blkg_destroy_all() clears the bit for every registered policy, including
the throttle policy:
for (i = 0; i < BLKCG_MAX_POLS; i++) {
struct blkcg_policy *pol = blkcg_policy[i];
if (pol)
__clear_bit(pol->plid, q->blkcg_pols);
}
When blk_throtl_exit() runs next, blkcg_policy_enabled() is already
false:
block/blk-throttle.c:blk_throtl_exit() {
if (!blk_throtl_activated(q))
return;
timer_delete_sync(&q->td->service_queue.pending_timer);
throtl_shutdown_wq(q);
blkcg_deactivate_policy(disk, &blkcg_policy_throtl);
kfree(q->td);
}
The function returns early whenever throttling was configured on the disk.
Can this leak struct throtl_data and skip timer_delete_sync() on
pending_timer and the dispatch_work shutdown in throtl_shutdown_wq()?
Before this patch the guard was only q->td != NULL, so this looks like a
regression from the changed predicate. I believe the timer and work are
normally idle on a dead queue, so the main effect is the leak of q->td.
The follow-up patch in this series, "ms/blk-throttle: fix throtl_data leak
during disk release", changes the guard in blk_throtl_exit() to
"if (!q->td) return;". That would fix this, but it leaves the intermediate
commit with the leak. Could the two be folded together, or ordered so
this one does not regress blk_throtl_exit()?
blk_throtl_cancel_bios() is not affected. It is called from del_gendisk()
before blkg_destroy_all(), so the throttle bit is still set there.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261102161219.3735623-1-den@openvz.org?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-02 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 16:12 [Devel] [PATCH hci-8.1 0/2] blk-throttle: fix a host panic setting the first throttle limit on a disk under I/O Denis V. Lunev
2026-11-02 16:12 ` [Devel] [PATCH hci-8.1 1/2] ms/blk-throttle: fix access race during throttle policy activation Denis V. Lunev
2026-11-02 16:59 ` no-reply [this message]
2026-11-02 17:34 ` Konstantin Khorenko
2026-11-02 16:12 ` [Devel] [PATCH hci-8.1 2/2] ms/blk-throttle: fix throtl_data leak during disk release Denis V. Lunev
2026-11-02 16:58 ` no-reply
2026-11-02 17:24 ` [Devel] [PATCH hci-8.1 0/2] blk-throttle: fix a host panic setting the first throttle limit on a disk under I/O Konstantin Khorenko
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=010701a19d334d83-a30b270a-30d0-4a81-9a2e-e83dd8547c05-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=den@openvz.org \
--cc=devel@openvz.org \
/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