From: Jens Axboe Date: Fri, 24 Feb 2017 20:19:32 +0000 (-0700) Subject: dm-rq: don't dereference request payload after ending request X-Git-Tag: v5.15~11806^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61febef40bfe8ab68259d8545257686e8a0d91d1;p=platform%2Fkernel%2Flinux-starfive.git dm-rq: don't dereference request payload after ending request Bart reported a case where dm would crash with use-after-free poison. This is due to dm_softirq_done() accessing memory associated with a request after calling end_request on it. This is most visible on !blk-mq, since we free the memory immediately for that case. Reported-by: Bart Van Assche Suggested-by: Linus Torvalds Fixes: eb8db831be80 ("dm: always defer request allocation to the owner of the request_queue") Signed-off-by: Jens Axboe --- diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 67d76f2..28955b9 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -328,13 +328,15 @@ static void dm_softirq_done(struct request *rq) int rw; if (!clone) { - rq_end_stats(tio->md, rq); + struct mapped_device *md = tio->md; + + rq_end_stats(md, rq); rw = rq_data_dir(rq); if (!rq->q->mq_ops) blk_end_request_all(rq, tio->error); else blk_mq_end_request(rq, tio->error); - rq_completed(tio->md, rw, false); + rq_completed(md, rw, false); return; }