aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-09-22 23:58:07 +0200
committerMoyster <oysterized@gmail.com>2016-08-26 20:44:55 +0200
commitbb2669d589dd50d538180f6a7d44e2104cfe3765 (patch)
tree19a263fb98074bf8de0ed6be785309281bf94295 /drivers
parent1fd768bea58c82f3b97232e0715ebd01e764d0dc (diff)
UBI: Validate data_size
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stefan Guendhoer <stefan@guendhoer.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/io.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 2000b8f0e..167eb36b8 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -945,6 +945,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
goto bad;
}
+ if (data_size > ubi->leb_size) {
+ ubi_err("bad data_size");
+ goto bad;
+ }
+
if (vol_type == UBI_VID_STATIC) {
/*
* Although from high-level point of view static volumes may