]> git.hungrycats.org Git - linux/commitdiff
dm writecache: fix a crash due to reading past end of dirty_bitmap
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 16 Aug 2018 16:23:19 +0000 (12:23 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Sep 2018 08:32:34 +0000 (10:32 +0200)
commit 1e1132ea21da6d7be92a72195204379c819cb70b upstream.

wc->dirty_bitmap_size is in bytes so must multiply it by 8, not by
BITS_PER_LONG, to get number of bitmap_bits.

Fixes crash in find_next_bit() that was reported:
https://bugzilla.kernel.org/show_bug.cgi?id=200819

Reported-by: edo.rus@gmail.com
Fixes: 48debafe4f2f ("dm: add writecache target")
Cc: stable@vger.kernel.org # 4.18
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-writecache.c

index 87107c995cb5be3a25b33b10b737ec1ac0dc3fea..7669069005e952f69281b61701e7ba616929bf30 100644 (file)
@@ -457,7 +457,7 @@ static void ssd_commit_flushed(struct dm_writecache *wc)
                COMPLETION_INITIALIZER_ONSTACK(endio.c),
                ATOMIC_INIT(1),
        };
-       unsigned bitmap_bits = wc->dirty_bitmap_size * BITS_PER_LONG;
+       unsigned bitmap_bits = wc->dirty_bitmap_size * 8;
        unsigned i = 0;
 
        while (1) {