Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1546045 > unrolled thread

[PATCH] mtd/redboot: avoid null pointer deref

Started by"Jason A. Donenfeld" <Jason@zx2c4.com>
First post2016-12-22 00:30 +0100
Last post2017-01-03 03:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mtd/redboot: avoid null pointer deref "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-22 00:30 +0100
    Re: [PATCH] mtd/redboot: avoid null pointer deref Marek Vasut <marek.vasut@gmail.com> - 2017-01-03 03:30 +0100

#1546045 — [PATCH] mtd/redboot: avoid null pointer deref

From"Jason A. Donenfeld" <Jason@zx2c4.com>
Date2016-12-22 00:30 +0100
Subject[PATCH] mtd/redboot: avoid null pointer deref
Message-ID<sQYuB-1qn-9@gated-at.bofh.it>
By giving a bogus partition name, it's possible to trigger a null
pointer dereference.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/mtd/redboot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index 7623ac5fc586..53949ef80d36 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -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++;
-- 
2.11.0

[toc] | [next] | [standalone]


#1549502

FromMarek Vasut <marek.vasut@gmail.com>
Date2017-01-03 03:30 +0100
Message-ID<sVn1n-7Oa-5@gated-at.bofh.it>
In reply to#1546045
On 12/22/2016 12:25 AM, Jason A. Donenfeld wrote:
> By giving a bogus partition name, it's possible to trigger a null
> pointer dereference.
> 
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

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 <marek.vasut@gmail.com>

Thanks

> ---
>  drivers/mtd/redboot.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
> index 7623ac5fc586..53949ef80d36 100644
> --- a/drivers/mtd/redboot.c
> +++ b/drivers/mtd/redboot.c
> @@ -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++;
> 


-- 
Best regards,
Marek Vasut

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web