Skip to content

Commit 61febef

Browse files
committed
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 <bart.vanassche@sandisk.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Fixes: eb8db83 ("dm: always defer request allocation to the owner of the request_queue") Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent d38d351 commit 61febef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/md/dm-rq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,15 @@ static void dm_softirq_done(struct request *rq)
328328
int rw;
329329

330330
if (!clone) {
331-
rq_end_stats(tio->md, rq);
331+
struct mapped_device *md = tio->md;
332+
333+
rq_end_stats(md, rq);
332334
rw = rq_data_dir(rq);
333335
if (!rq->q->mq_ops)
334336
blk_end_request_all(rq, tio->error);
335337
else
336338
blk_mq_end_request(rq, tio->error);
337-
rq_completed(tio->md, rw, false);
339+
rq_completed(md, rw, false);
338340
return;
339341
}
340342

0 commit comments

Comments
 (0)