Skip to content

RFC blk-mq: Avoid use-after-free for accessing old requests

John Garry linux-block lkml oe-kbuild-all 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 RFC Latest3 patches 26 repliesIn review
  2. v2 RFC2 patches 20 repliesSuperseded
  3. v1 RFC1 patch 12 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3blk-mq: Clean up references to old requests when freeing rqsblock/blk-mq-sched.c block/blk-mq-tag.c block/blk-mq.c +1 more+22 -44 replies
2/3blk-mq: Freeze and quiesce all queues for tagset in elevator_exit()block/blk.h+19 -013 replies
3/3blk-mq: Lockout tagset iterator when exiting elevatorblock/blk-mq-tag.c block/blk-mq.c block/blk.h +1 more+11 -08 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchBart Van Assche
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [RFC PATCH v3 0/3] blk-mq: Avoid use-after-free for accessing old requests

This series aims to tackle the various UAF reports, like:
[0] https://lore.kernel.org/linux-block/[email protected]/
[1] https://lore.kernel.org/linux-block/[email protected]/T/#m6c1ac11540522716f645d004e2a5a13c9f218908
[2] https://lore.kernel.org/linux-block/[email protected]/
[3] https://lore.kernel.org/linux-block/[email protected]/

Details are in the commit messages.

The issue addressed in patch 1/3 is pretty easy to reproduce, 2+3/3 not so much, and I had to add mdelays in the iters functions to recreate in sane timeframes.

A regards patch 1/3, if 2+3/3 are adopted, then this can simplified to simply clear the tagset requests pointers without using any atomic operations. However, this patch on its own seems to solve the problem [3], above. So the other 2x patches are really for extreme scenarios which may never be seen in practice. As such, it could be considered to just accept patch 1/3 now.

Differences to v2:
- Add patch 2+3/3
- Drop patch to lockout blk_mq_queue_tag_busy_iter() when exiting elevator

John Garry (3):
blk-mq: Clean up references to old requests when freeing rqs
blk-mq: Freeze and quiesce all queues for tagset in elevator_exit()
blk-mq: Lockout tagset iterator when exiting elevator

 block/blk-mq-sched.c   |  2 +-
 block/blk-mq-tag.c     |  7 ++++++-
 block/blk-mq.c         | 21 +++++++++++++++++++--
 block/blk-mq.h         |  2 ++
 block/blk.h            | 23 +++++++++++++++++++++++
 include/linux/blk-mq.h |  1 +
 6 files changed, 52 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.2