blk-mq: Avoid race condition with uninitialized requests
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Thu, 18 Sep 2014 09:04:31 +0000 (11:04 +0200)
committerJens Axboe <axboe@fb.com>
Mon, 30 Mar 2015 18:54:55 +0000 (12:54 -0600)
commit49a34302ed2dae792e260cdad0dcc29931fb969e
tree6c2c5e38bd9062d3a6fba58be512619734d61452
parentfccefb687af3e1683451fcee5be3acf19140d71f
blk-mq: Avoid race condition with uninitialized requests

This patch should fix the bug reported in
https://lkml.org/lkml/2014/9/11/249.

We have to initialize at least the atomic_flags and the cmd_flags when
allocating storage for the requests.

Otherwise blk_mq_timeout_check() might dereference uninitialized
pointers when racing with the creation of a request.

Also move the reset of cmd_flags for the initializing code to the point
where a request is freed. So we will never end up with pending flush
request indicators that might trigger dereferences of invalid pointers
in blk_mq_timeout_check().

Cc: stable@vger.kernel.org
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c