]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
UBI: Validate data_size
authorRichard Weinberger <richard@nod.at>
Tue, 22 Sep 2015 21:58:07 +0000 (23:58 +0200)
committerZefan Li <lizefan@huawei.com>
Wed, 27 Apr 2016 10:55:25 +0000 (18:55 +0800)
commit 281fda27673f833a01d516658a64d22a32c8e072 upstream.

Make sure that data_size is less than LEB size.
Otherwise a handcrafted UBI image is able to trigger
an out of bounds memory access in ubi_compare_lebs().

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
[lizf: Backported to 3.4: use dbg_err() instead of ubi_err()];
Signed-off-by: Zefan Li <lizefan@huawei.com>
drivers/mtd/ubi/io.c

index 43f1a0011a55cad9a9d876cff0241ecda9876ba3..8f793ea1d23a677c649208040e61a65e385ccfb9 100644 (file)
@@ -942,6 +942,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
                goto bad;
        }
 
+       if (data_size > ubi->leb_size) {
+               dbg_err("bad data_size");
+               goto bad;
+       }
+
        if (vol_type == UBI_VID_STATIC) {
                /*
                 * Although from high-level point of view static volumes may