Re: [PATCH 1/5] mtd: block2mtd: Check for valid user supplied erase size

From: Richard Weinberger
Date: Fri Jul 21 2017 - 15:45:51 EST


On Fri, Jun 2, 2017 at 5:43 PM, Pali RohÃr <pali.rohar@xxxxxxxxx> wrote:
> Erase size is limited to 32bit unsigned integer, but value parsed from user
> is limited up to size_t C type.
>
> Signed-off-by: Pali RohÃr <pali.rohar@xxxxxxxxx>
> ---
> drivers/mtd/devices/block2mtd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
> index 7c887f1..ee47cdd 100644
> --- a/drivers/mtd/devices/block2mtd.c
> +++ b/drivers/mtd/devices/block2mtd.c
> @@ -419,7 +419,7 @@ static int block2mtd_setup2(const char *val)
>
> if (token[1]) {
> ret = parse_num(&erase_size, token[1]);
> - if (ret) {
> + if (ret || erase_size > U32_MAX) {
> pr_err("illegal erase size\n");
> return 0;
> }

Reviewed-by: Richard Weinberger <richard@xxxxxx>

--
Thanks,
//richard