diff options
author | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2016-05-16 09:54:47 -0600 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-08-22 22:37:59 +0100 |
commit | 66003d803e3df727cfbe578f8d0a2b952ecbacdc (patch) | |
tree | cd66595571e0a4802b622e85cca85a2c9c3f22af /block | |
parent | c47ae034bb55f6fee5c8121403a454130e8eca95 (diff) | |
download | linux-stable-66003d803e3df727cfbe578f8d0a2b952ecbacdc.tar.gz linux-stable-66003d803e3df727cfbe578f8d0a2b952ecbacdc.tar.bz2 linux-stable-66003d803e3df727cfbe578f8d0a2b952ecbacdc.zip |
blk-mq: fix undefined behaviour in order_to_size()
commit b3a834b1596ac668df206aa2bb1f191c31f5f5e4 upstream.
When this_order variable in blk_mq_init_rq_map() becomes zero
the code incorrectly decrements the variable and passes the result
to order_to_size() helper causing undefined behaviour:
UBSAN: Undefined behaviour in block/blk-mq.c:1459:27
shift exponent 4294967295 is too large for 32-bit type 'unsigned int'
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0-rc6-00072-g33656a1 #22
Fix the code by checking this_order variable for not having the zero
value first.
Reported-by: Meelis Roos <mroos@linux.ee>
Fixes: 320ae51feed5 ("blk-mq: new multi-queue block IO queueing mechanism")
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index 50dd29bc4972..31c4fa508e77 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1385,7 +1385,7 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set, int to_do; void *p; - while (left < order_to_size(this_order - 1) && this_order) + while (this_order && left < order_to_size(this_order - 1)) this_order--; do { |