Skip to content

Commit 74c9c91

Browse files
JeffMoyeraxboe
authored andcommitted
mtip32x: fix regression introduced by blk-mq per-hctx flush
Hi, After commit f70ced0 (blk-mq: support per-distpatch_queue flush machinery), the mtip32xx driver may oops upon module load due to walking off the end of an array in mtip_init_cmd. On initialization of the flush_rq, init_request is called with request_index >= the maximum queue depth the driver supports. For mtip32xx, this value is used to index into an array. What this means is that the driver will walk off the end of the array, and either oops or cause random memory corruption. The problem is easily reproduced by doing modprobe/rmmod of the mtip32xx driver in a loop. I can typically reproduce the problem in about 30 seconds. Now, in the case of mtip32xx, it actually doesn't support flush/fua, so I think we can simply return without doing anything. In addition, no other mq-enabled driver does anything with the request_index passed into init_request(), so no other driver is affected. However, I'm not really sure what is expected of drivers. Ming, what did you envision drivers would do when initializing the flush requests? Signed-off-by: Jeff Moyer <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 006a097 commit 74c9c91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,14 @@ static int mtip_init_cmd(void *data, struct request *rq, unsigned int hctx_idx,
37563756
struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
37573757
u32 host_cap_64 = readl(dd->mmio + HOST_CAP) & HOST_CAP_64;
37583758

3759+
/*
3760+
* For flush requests, request_idx starts at the end of the
3761+
* tag space. Since we don't support FLUSH/FUA, simply return
3762+
* 0 as there's nothing to be done.
3763+
*/
3764+
if (request_idx >= MTIP_MAX_COMMAND_SLOTS)
3765+
return 0;
3766+
37593767
cmd->command = dmam_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
37603768
&cmd->command_dma, GFP_KERNEL);
37613769
if (!cmd->command)

0 commit comments

Comments
 (0)