mtd: properly check all write ioctls for permissions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jul 2020 11:53:46 +0000 (13:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 09:01:54 +0000 (11:01 +0200)
commit583d42400532fbd6228b0254d7c732b771e4750d
tree7d8b5f7e54bfe4093df3a539bdc1ef13a4872d05
parent8c19b606e78a2b08e1ea69eebd5c290913c89612
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