Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 66b99c5d authored by Ming Lei's avatar Ming Lei Committed by Surapusetty Naresh Babu
Browse files

BACKPORT: blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter



Grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter(), and
this way will prevent the request from being re-used when ->fn is
running. The approach is same as what we do during handling timeout.

Fix request use-after-free(UAF) related with completion race or queue
releasing:

- If one rq is referred before rq->q is frozen, then queue won't be
frozen before the request is released during iteration.

- If one rq is referred after rq->q is frozen, refcount_inc_not_zero()
will return false, and we won't iterate over this request.

However, still one request UAF not covered: refcount_inc_not_zero() may
read one freed request, and it will be handled in next patch.

Tested-by: default avatarJohn Garry <john.garry@huawei.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com&gt;.>

Bug: 197804811
Change-Id: Ib80fe8b9f1d76d2489e41f3365fbd12d68a3b097
[Pradeep: Resolved conflicts in block/blk-mq-tag.c]
Git-commit: a5d38e7c26ca21a544635732a711176017663168
Git-repo: https://android.googlesource.com/kernel/common/


Signed-off-by: default avatarPradeep P V K <quic_pragalla@quicinc.com>
(cherry picked from commit f3b26aea)

Change-Id: I88aed73876e4126b1144604a66c61c0f79f40116
Signed-off-by: default avatarSurapusetty Naresh Babu <snareshb@qti.qualcomm.com>
parent f3875bf8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment