* [PATCH] mtd/ubi: Make sure to read volume record from LEB 0 or LEB 1
@ 2018-08-20 6:09 Liu Song
2018-08-20 20:21 ` Richard Weinberger
0 siblings, 1 reply; 2+ messages in thread
From: Liu Song @ 2018-08-20 6:09 UTC (permalink / raw)
To: dedekind1, richard
Cc: linux-mtd, linux-kernel, liu.song11, jiang.biao2, zhong.weidong
From: fishland <liu.song11@zte.com.cn>
Even though we protect on-flash data by CRC checksums,
we still don't trust the media. If lnum is not 0 or 1,
access exceed array boundary can lead to bad situation.
Signed-off-by: Liu Song <liu.song11@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
---
drivers/mtd/ubi/vtbl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 94d7a86..64a2937 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -410,6 +410,10 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
/* Read both LEB 0 and LEB 1 into memory */
ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) {
+ if (aeb->lnum != 0 && aeb->lnum != 1) {
+ ubi_warn(ubi, "volume store in LEB %d", aeb->lnum);
+ continue;
+ }
leb[aeb->lnum] = vzalloc(ubi->vtbl_size);
if (!leb[aeb->lnum]) {
err = -ENOMEM;
--
2.1.0.GIT
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd/ubi: Make sure to read volume record from LEB 0 or LEB 1
2018-08-20 6:09 [PATCH] mtd/ubi: Make sure to read volume record from LEB 0 or LEB 1 Liu Song
@ 2018-08-20 20:21 ` Richard Weinberger
0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2018-08-20 20:21 UTC (permalink / raw)
To: Liu Song; +Cc: dedekind1, linux-mtd, linux-kernel, jiang.biao2, zhong.weidong
Lui Song,
Am Montag, 20. August 2018, 08:09:05 CEST schrieb Liu Song:
> From: fishland <liu.song11@zte.com.cn>
Please use your real name. 1st Signed-off-by and patch author should match.
> Even though we protect on-flash data by CRC checksums,
> we still don't trust the media. If lnum is not 0 or 1,
> access exceed array boundary can lead to bad situation.
Good find! I'll queue this for the next fixes-pull-request.
Thanks,
//richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-20 20:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20 6:09 [PATCH] mtd/ubi: Make sure to read volume record from LEB 0 or LEB 1 Liu Song
2018-08-20 20:21 ` Richard Weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).