]> git.baikalelectronics.ru Git - kernel.git/commit
drm/etnaviv: Use FOLL_FORCE for userptr
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 1 Mar 2021 09:52:53 +0000 (10:52 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 19 Mar 2021 19:15:27 +0000 (20:15 +0100)
commit26cf911ec13a59a2446938e8de1148d852f512d2
treeb06fb1ba811f436e71dcecad7258c77e9108c602
parent60ea29db7c5b4d164d2851cd534b0eef133ec282
drm/etnaviv: Use FOLL_FORCE for userptr

Nothing checks userptr.ro except this call to pup_fast, which means
there's nothing actually preventing userspace from writing to this.
Which means you can just read-only mmap any file you want, userptr it
and then write to it with the gpu. Not good.

The right way to handle this is FOLL_WRITE | FOLL_FORCE, which will
break any COW mappings and update tracking for MAY_WRITE mappings so
there's no exploit and the vm isn't confused about what's going on.
For any legit use case there's no difference from what userspace can
observe and do.

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: stable@vger.kernel.org
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Russell King <linux+etnaviv@armlinux.org.uk>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: etnaviv@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20210301095254.1946084-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/etnaviv/etnaviv_gem.c