drm/i915/userptr: Hold mmref whilst calling get-user-pages
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 5 Apr 2016 14:00:00 +0000 (15:00 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Apr 2016 19:39:01 +0000 (20:39 +0100)
commit40313f0cd0b711a7a5905e5182422799e157d8aa
tree348c8ad14d42c1b12903b26560351b3062b422d5
parent393afc2c3fda670ff392725ca618e956d625b964
drm/i915/userptr: Hold mmref whilst calling get-user-pages

Holding a reference to the containing task_struct is not sufficient to
prevent the mm_struct from being reaped under memory pressure. If this
happens whilst we are calling get_user_pages(), explosions erupt -
sometimes an immediate GPF, sometimes page flag corruption. To prevent
the target mm from being reaped as we are reading from it, acquire a
reference before we begin.

Testcase: igt/gem_shrink/*userptr
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: stable@vger.kernel.org
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1459864801-28606-2-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_userptr.c