Skip to content

blk-mq: fix use-after-free on stale request

Ming Lei linux-block 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5blk-mq: define max_order for allocating rqs pages as macroblock/blk-mq.c+4 -20 replies
2/5blk-mq: add helper of blk_mq_get_hw_queue_nodeblock/blk-mq.c+14 -101 reply
3/5blk-mq: add helpers for allocating/freeing pages of request poolblock/blk-mq.c+51 -300 replies
4/5blk-mq: cache freed request pool pagesblock/blk-mq.c include/linux/blk-mq.h+87 -140 replies
5/5blk-mq: check and shrink freed request pool pageblock/blk-mq.c include/linux/blk-mq.h+56 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] blk-mq: fix use-after-free on stale request

Hi,

We can't run allocating driver tag and updating tags->rqs[tag] atomically, so stale request may be retrieved from tags->rqs[tag]. More seriously, the stale request may have been freed via updating nr_requests or switching elevator or other use cases.

It is one long-term issue, and Jianchao previous worked towards using static_rqs[] for iterating request, one problem is that it can be hard to use when iterating over tagset.

This patchset takes another different approach for fixing the issue: cache freed rqs pages and release them until all tags->rqs[] references on these pages are gone.

Please review and comment.

[1] https://lore.kernel.org/linux-block/[email protected]/
[2] https://marc.info/?t=154526200600007&r=2&w=2

Ming Lei (5):
blk-mq: define max_order for allocating rqs pages as macro
blk-mq: add helper of blk_mq_get_hw_queue_node
blk-mq: add helpers for allocating/freeing pages of request pool
blk-mq: cache freed request pool pages
blk-mq: check and shrink freed request pool page

 block/blk-mq.c         | 236 +++++++++++++++++++++++++++++++++--------
 include/linux/blk-mq.h |   4 +
 2 files changed, 198 insertions(+), 42 deletions(-)
Cc Hannes Reinecke <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc John Garry <[email protected]>
Cc Christoph Hellwig <[email protected]>
Signature · 1 line
2.25.2