From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: mkoutny@suse.com, tj@kernel.org, bpf@vger.kernel.org, hannes@cmpxchg.org
Subject: Re: [RFC PATCH v8 1/4] blk-iocost: add BPF struct_ops cost model support
Date: Wed, 30 Sep 2026 08:11:23 +0000 [thread overview]
Message-ID: <20260930081123.8CDA91F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260930075154.189958-2-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] block: Use-After-Free in q_to_ioc() list traversal due to dropped rq_qos_mutex
--
commit 18772c6b40ac8eb626b52af0f79d379ddd873095
Author: Tao Cui <cui.tao@linux.dev>
blk-iocost: add BPF struct_ops cost model support
This commit adds BPF struct_ops support to blk-iocost, allowing a BPF
program to fully replace the builtin linear cost model for a device.
It registers the iocost_model_ops struct_ops type and binds the custom
cost model to the target device's block cgroup paths.
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -3584,6 +3584,204 @@ static int ioc_cost_model_show(struct seq_file *sf, void *v)
> return 0;
> }
>
> +#ifdef CONFIG_BLK_CGROUP_IOCOST_BPF
[ ... ]
> +int ioc_bpf_attach(struct iocost_model_ops *ops)
> +{
> + struct block_device *bdev;
> + struct request_queue *q;
> + struct gendisk *disk;
> + struct ioc *ioc;
> + unsigned int memflags;
> + int ret;
[ ... ]
> + mutex_lock(&q->rq_qos_mutex);
> + if (!disk_live(disk) || !blk_get_queue(q)) {
> + mutex_unlock(&q->rq_qos_mutex);
> + ret = -ENODEV;
> + goto put;
> + }
> + ioc = q_to_ioc(q);
> + if (!ioc) {
> + ret = blk_iocost_init(disk);
> + mutex_unlock(&q->rq_qos_mutex);
> + if (ret)
> + goto put_q;
> + ioc = q_to_ioc(q);
[Severity: High]
Is it safe to call q_to_ioc() here after dropping rq_qos_mutex?
q_to_ioc() internally calls rq_qos_id(), which traverses the non-RCU
q->rq_qos linked list locklessly. Because the protecting rq_qos_mutex
is unlocked just prior to this call, could a concurrent thread (such as
one disabling another QoS policy via sysfs, or a device removal triggering
rq_qos_exit()) modify the list and cause a use-after-free during this
unprotected traversal?
> + } else {
> + mutex_unlock(&q->rq_qos_mutex);
> + }
> +
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930075154.189958-1-cui.tao@linux.dev?part=1
next prev parent reply other threads:[~2026-09-30 8:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 7:51 [RFC PATCH v8 0/4] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-09-30 7:51 ` [RFC PATCH v8 1/4] " Tao Cui
2026-09-30 8:11 ` sashiko-bot [this message]
2026-09-30 11:50 ` Tao Cui
2026-10-01 0:20 ` Tejun Heo
2026-10-02 14:17 ` Tao Cui
2026-09-30 7:51 ` [RFC PATCH v8 2/4] selftests/bpf: add iocost cost model test Tao Cui
2026-09-30 8:02 ` sashiko-bot
2026-10-01 0:20 ` Tejun Heo
2026-10-02 14:20 ` Tao Cui
2026-09-30 7:51 ` [RFC PATCH v8 3/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-10-01 0:20 ` Tejun Heo
2026-10-02 14:22 ` Tao Cui
2026-09-30 7:51 ` [RFC PATCH v8 4/4] docs: cgroup-v2: document the iocost BPF cost model attachment Tao Cui
2026-09-30 8:45 ` bot+bpf-ci
2026-10-01 0:20 ` Tejun Heo
2026-10-02 14:23 ` Tao Cui
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=20260930081123.8CDA91F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cui.tao@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@kernel.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