Skip to content

blk-mq: fix out-of-bounds read in blk_mq_free_rqs - #1283

Open
blktests-ci-kpd[bot] wants to merge 1 commit into
linus-master_basefrom
series/1161970=>linus-master
Open

blktests-ci-kpd[bot] wants to merge 1 commit into
linus-master_basefrom
series/1161970=>linus-master

Conversation

@blktests-ci-kpd

Copy link
Copy Markdown

Pull request for series with
subject: blk-mq: fix out-of-bounds read in blk_mq_free_rqs
version: 1
url: https://patchwork.kernel.org/series/1161970/

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 50d05c7
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5225b8e
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from b825b3b to 933f964 Compare September 12, 2026 02:41
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 933f964 to a9c93ca Compare September 13, 2026 10:09
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from a9c93ca to 0ebb93c Compare September 13, 2026 23:11
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5878583
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 4982d35
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from c0f8db6 to 6510c44 Compare September 17, 2026 19:48
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5dd1818
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 6a5719c
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 9e81277 to 3b0cfe2 Compare September 20, 2026 21:04
@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 9182022 to 7171e5a Compare September 26, 2026 08:30
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 72d3fcf
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 7171e5a to 0a1d7da Compare September 28, 2026 15:22
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 551c722
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch 2 times, most recently from 0a1d7da to feba688 Compare October 1, 2026 16:13
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: ce1e022
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from feba688 to 5bd65da Compare October 1, 2026 23:52
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: e767a4e
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 5bd65da to 0c0b777 Compare October 3, 2026 10:15
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: a74306e
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 0c0b777 to 6deec4b Compare October 3, 2026 22:24
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: None
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 6deec4b to 9a34d97 Compare October 5, 2026 02:32
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 22430ae
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 9a34d97 to fff1779 Compare October 6, 2026 13:16
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 69f80fe
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from fff1779 to 25d18ae Compare October 6, 2026 17:29
A KASAN slab-out-of-bounds read can occur in blk_mq_free_rqs() when there
is a mismatch between the number of hardware queues allocated for the IO
scheduler (et->nr_hw_queues) and the number of hardware queues in the block
tag set (set->nr_hw_queues).

This mismatch can happen if blk_mq_update_nr_hw_queues() fails halfway
through (e.g., due to memory pressure during
blk_mq_prealloc_tag_set_tags()). In this error path, the elevator is
restored with a larger number of hardware queues than the block tag set
actually has.

When the elevator is later freed, blk_mq_free_sched_tags() iterates up to
the new et->nr_hw_queues and calls blk_mq_free_rqs(). In blk_mq_free_rqs(),
it attempts to access set->tags[hctx_idx] to get the driver tags. Because
set->nr_hw_queues was not updated due to the earlier failure, set->tags
still has the old (smaller) size, leading to an out-of-bounds read.

BUG: KASAN: slab-out-of-bounds in blk_mq_free_rqs+0xde/0x680
Read of size 8 at addr ffff88818d67fc28 by task syz-executor117/5839
Call Trace:
 blk_mq_free_rqs+0xde/0x680
 blk_mq_free_map_and_rqs+0x40/0xf0
 blk_mq_free_sched_tags
 blk_mq_free_sched_res+0xeb/0x280
 elevator_change_done+0x1d2/0x5c0
 elevator_change+0x34f/0x480
 elv_iosched_store+0x504/0x630
 queue_attr_store+0x207/0x2b0

To fix this, explicitly check if hctx_idx < set->nr_hw_queues before
accessing set->tags[hctx_idx]. If hctx_idx >= set->nr_hw_queues, the
hardware queue doesn't exist in the tag set, meaning there are no driver
tags to clear mappings from. In this case, safely set drv_tags to NULL. The
subsequent call to blk_mq_clear_rq_mapping() already handles a NULL
drv_tags pointer and will safely return.

This fix also prevents a similar out-of-bounds read in the failure path of
blk_mq_alloc_rqs(), where a failure during new driver tag allocation could
lead to blk_mq_free_rqs() being called with an hctx_idx greater than or
equal to set->nr_hw_queues.

Fixes: 04225d1 ("block: fix potential deadlock while running nr_hw_queue update")
Assisted-by: Gemini:gemini-3.5-flash Gemini:gemini-3.1-pro-preview syzbot
Reported-by: syzbot+e90526cab23b9efcd03c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e90526cab23b9efcd03c
Link: https://syzkaller.appspot.com/ai_job?id=827b5760-86a0-4f44-9c69-430b572eac12
Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Reviewed-by: Nilay Shorff <nilay@linux.ibm.com>
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 7b63ef2
series: https://patchwork.kernel.org/series/1161970/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1161970=>linus-master branch from 25d18ae to 61a71a6 Compare October 7, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants