[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20220609131022.293516-1-miquel.raynal@bootlin.com>
Date: Thu, 9 Jun 2022 15:10:22 +0200
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Michał Kępień <kernel@...pniu.pl>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] mtdchar: prevent integer overflow in a safety check
On Mon, 2022-05-16 at 07:06:00 UTC, =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= wrote:
> Commit 6420ac0af95d ("mtdchar: prevent unbounded allocation in MEMWRITE
> ioctl") added a safety check to mtdchar_write_ioctl() which attempts to
> ensure that the write request sent by user space does not extend beyond
> the MTD device's size. However, that check contains an addition of two
> struct mtd_write_req fields, 'start' and 'len', both of which are u64
> variables. The result of that addition can overflow, allowing the
> safety check to be bypassed.
>
> The arguably simplest fix - changing the data types of the relevant
> struct mtd_write_req fields - is not feasible as it would break user
> space.
>
> Fix by making mtdchar_write_ioctl() truncate the value provided by user
> space in the 'len' field of struct mtd_write_req, so that only the lower
> 32 bits of that field are used, preventing the overflow.
>
> While the 'ooblen' field of struct mtd_write_req is not currently used
> in any similarly flawed safety check, also truncate it to 32 bits, for
> consistency with the 'len' field and with other MTD routines handling
> OOB data.
>
> Update include/uapi/mtd/mtd-abi.h accordingly.
>
> Suggested-by: Richard Weinberger <richard@....at>
> Signed-off-by: Michał Kępień <kernel@...pniu.pl>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
Powered by blists - more mailing lists