Skip to content

Commit

Permalink
blk-mq: add bounds check on tag-to-rq conversion
Browse files Browse the repository at this point in the history
We need to check for a valid index before accessing the array
element to avoid accessing invalid memory regions.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Modified by Jens to drop the unlikely(), and make the fall through
path be having a valid tag.

Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Hannes Reinecke authored and Jens Axboe committed Mar 15, 2016
1 parent 2b88551 commit 4ee86ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,10 @@ EXPORT_SYMBOL(blk_mq_abort_requeue_list);

struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
{
return tags->rqs[tag];
if (tag < tags->nr_tags)
return tags->rqs[tag];

return NULL;
}
EXPORT_SYMBOL(blk_mq_tag_to_rq);

Expand Down

0 comments on commit 4ee86ba

Please sign in to comment.