mtd: properly check all write ioctls for permissions
commit9a53e8bd59d9f070505e51d3fd19606a270e6b93
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jul 2020 11:53:46 +0000 (16 13:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Aug 2020 13:33:35 +0000 (11 15:33 +0200)
treee5b01bdfeb938ac79debb5d010444f041bc1714a
parent8c3215a0426c404f4b7b02a1e0fdb0f7f4f1e6d3
mtd: properly check all write ioctls for permissions

commit f7e6b19bc76471ba03725fe58e0c218a3d6266c3 upstream.

When doing a "write" ioctl call, properly check that we have permissions
to do so before copying anything from userspace or anything else so we
can "fail fast".  This includes also covering the MEMWRITE ioctl which
previously missed checking for this.

Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[rw: Fixed locking issue]
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/mtdchar.c