aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/mtd
diff options
context:
space:
mode:
authorMichał Kępień <kernel@kempniu.pl>2022-05-16 09:06:00 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2022-06-09 15:03:32 +0200
commita1eda864c04cf24ea1130334963c6199318f6f95 (patch)
treee6c3f975967ab36079736d3130cb48ca6bc27e52 /include/uapi/mtd
parentmtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset (diff)
downloadlinux-dev-a1eda864c04cf24ea1130334963c6199318f6f95.tar.xz
linux-dev-a1eda864c04cf24ea1130334963c6199318f6f95.zip
mtdchar: prevent integer overflow in a safety check
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@nod.at> Signed-off-by: Michał Kępień <kernel@kempniu.pl> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20220516070601.11428-2-kernel@kempniu.pl
Diffstat (limited to 'include/uapi/mtd')
-rw-r--r--include/uapi/mtd/mtd-abi.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h
index b869990c2db2..890d9e5b76d7 100644
--- a/include/uapi/mtd/mtd-abi.h
+++ b/include/uapi/mtd/mtd-abi.h
@@ -69,8 +69,8 @@ enum {
* struct mtd_write_req - data structure for requesting a write operation
*
* @start: start address
- * @len: length of data buffer
- * @ooblen: length of OOB buffer
+ * @len: length of data buffer (only lower 32 bits are used)
+ * @ooblen: length of OOB buffer (only lower 32 bits are used)
* @usr_data: user-provided data buffer
* @usr_oob: user-provided OOB buffer
* @mode: MTD mode (see "MTD operation modes")