summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2016-05-27 09:44:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-27 12:30:27 +0200
commit2258208ae2ed8d36fa7217a453bf0f2de642bbda (patch)
treea519b628cb9f174fdfce9ecb4dd55e4cdf382995
parent35fd94ee9568be4eaddc31dc07958f74fa97df09 (diff)
downloadbarebox-2258208ae2ed8d36fa7217a453bf0f2de642bbda.tar.gz
barebox-2258208ae2ed8d36fa7217a453bf0f2de642bbda.tar.xz
UBI: Validate data_size
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: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-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 bb38b79def..655ab50438 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -618,6 +618,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
goto bad;
}
+ if (data_size > ubi->leb_size) {
+ ubi_err(ubi, "bad data_size");
+ goto bad;
+ }
+
if (vol_type == UBI_VID_STATIC) {
/*
* Although from high-level point of view static volumes may