[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7875bf6f-faf4-5612-1d82-0f16a58f8455@huawei.com>
Date: Wed, 24 Jan 2024 15:20:47 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Richard Weinberger <richard@....at>, <linux-mtd@...ts.infradead.org>
CC: <linux-kernel@...r.kernel.org>, Chenyuan Yang <cy54@...inois.edu>,
<stable@...r.kernel.org>
Subject: Re: [PATCH] ubi: Check for too small LEB size in VTBL code
在 2024/1/24 14:37, Richard Weinberger 写道:
> If the LEB size is smaller than a volume table record we cannot
> have volumes.
> In this case abort attaching.
>
> Cc: Chenyuan Yang <cy54@...inois.edu>
> Cc: stable@...r.kernel.org
> Fixes: 801c135ce73d ("UBI: Unsorted Block Images")
> Reported-by: Chenyuan Yang <cy54@...inois.edu>
> Closes: https://lore.kernel.org/linux-mtd/1433EB7A-FC89-47D6-8F47-23BE41B263B3@illinois.edu/
> Signed-off-by: Richard Weinberger <richard@....at>
> ---
> drivers/mtd/ubi/vtbl.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@...wei.com>
>
> diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
> index f700f0e4f2ec..6e5489e233dd 100644
> --- a/drivers/mtd/ubi/vtbl.c
> +++ b/drivers/mtd/ubi/vtbl.c
> @@ -791,6 +791,12 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
> * The number of supported volumes is limited by the eraseblock size
> * and by the UBI_MAX_VOLUMES constant.
> */
> +
> + if (ubi->leb_size < UBI_VTBL_RECORD_SIZE) {
> + ubi_err(ubi, "LEB size too small for a volume record");
> + return -EINVAL;
> + }
> +
> ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE;
> if (ubi->vtbl_slots > UBI_MAX_VOLUMES)
> ubi->vtbl_slots = UBI_MAX_VOLUMES;
>
Powered by blists - more mailing lists