summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-09-22 23:58:07 +0200
committerSasha Levin <sasha.levin@oracle.com>2015-10-27 22:14:15 -0400
commitdded44f1aff46ef9cfdcecc52a7688a4b1c73004 (patch)
treee2cdc08b3b4ee4ea599ddb272e08ebf1d0751511 /drivers/mtd
parent5b12405cd01699eb0ac6784fb3cd9fb53e80dfd7 (diff)
UBI: Validate data_size
[ Upstream commit 281fda27673f833a01d516658a64d22a32c8e072 ] 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(). Cc: stable@vger.kernel.org Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: David Gstir <david@sigma-star.at> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'drivers/mtd')
-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 d36134925d31..db657f2168d7 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -921,6 +921,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