mtd/redboot: avoid null pointer deref
PATCH 1/1 mtd/redboot: avoid null pointer deref
By giving a bogus partition name, it's possible to trigger a null pointer dereference.
Signed-off-by Jason A. Donenfeld <[email protected]>
--- drivers/mtd/redboot.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/redboot.c +4 -0
@@ -212,6 +212,10 @@ static int parse_redboot_partitions(struct mtd_info *master, nrparts++; } +if (!fl) { + ret = -EINVAL ; + goto out; + }#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED if (fl->img->flash_base) { nrparts++;
Signature · 1 line
2.11.0
Quoted 4 lines · Jason A. Donenfeld
By giving a bogus partition name, it's possible to trigger a null pointer dereference.
Signed-off-by Jason A. Donenfeld <[email protected]>
Nice catch. It'd be great to have the condition which can be used to trigger this problem in the commit message. I presume this happens if buf[i].name[0] = 0xff for all $i, right ?
So please expand the explanation and add my Ack for V2:
Acked-by Marek Vasut <[email protected]>
Thanks
Quoted 20 lines
--- drivers/mtd/redboot.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mtd/redboot.c +4
-0@@ -212,6 +212,10 @@ static int parse_redboot_partitions(struct mtd_info *master, nrparts++; } +if (!fl) { + ret = -EINVAL ; + goto out; + }#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED if (fl->img->flash_base) { nrparts++;
Signature · 2 lines
Best regards, Marek Vasut