]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
lib: fix stall in __bitmap_parselist()
authorYury Norov <ynorov@caviumnetworks.com>
Thu, 5 Apr 2018 23:18:25 +0000 (16:18 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 22 May 2018 14:18:33 +0000 (16:18 +0200)
commitdad4f5a61d6170d028b49f016601b00b1e0930b9
treeb24647a58e43fcb05999f636544d1852ba31a9e2
parentef7ba5935c48fad738d9839aca5df3f5ce9bf8c6
lib: fix stall in __bitmap_parselist()

BugLink: http://bugs.launchpad.net/bugs/1769723
commit 8351760ff5b2042039554b4948ddabaac644a976 upstream.

syzbot is catching stalls at __bitmap_parselist()
(https://syzkaller.appspot.com/bug?id=ad7e0351fbc90535558514a71cd3edc11681997a).
The trigger is

  unsigned long v = 0;
  bitmap_parselist("7:,", &v, BITS_PER_LONG);

which results in hitting infinite loop at

    while (a <= b) {
    off = min(b - a + 1, used_size);
    bitmap_set(maskp, a, off);
    a += group_size;
    }

due to used_size == group_size == 0.

Link: http://lkml.kernel.org/r/20180404162647.15763-1-ynorov@caviumnetworks.com
Fixes: 0a5ce0831d04382a ("lib/bitmap.c: make bitmap_parselist() thread-safe and much faster")
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+6887cbb011c8054e8a3d@syzkaller.appspotmail.com>
Cc: Noam Camus <noamca@mellanox.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
lib/bitmap.c
lib/test_bitmap.c