Home Home > GIT Browse > SLE12-SP3-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2019-02-18 10:34:34 +0100
committerThomas Zimmermann <tzimmermann@suse.de>2019-02-18 13:19:53 +0100
commit1dcecceb409135e894fc72f51a4b0dd3b46e973c (patch)
treeb41027d044714f5bf3cb1d4defe88c986628ee25
parentda09028ffeb974ea7379ab15869d8c14ce98d2e9 (diff)
drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set (bsc#1106929)
-rw-r--r--patches.fixes/0004-drm-i915-Prevent-a-race-during-I915_GEM_MMAP-ioctl-w.patch65
-rw-r--r--series.conf1
2 files changed, 66 insertions, 0 deletions
diff --git a/patches.fixes/0004-drm-i915-Prevent-a-race-during-I915_GEM_MMAP-ioctl-w.patch b/patches.fixes/0004-drm-i915-Prevent-a-race-during-I915_GEM_MMAP-ioctl-w.patch
new file mode 100644
index 0000000000..9e1afc6c08
--- /dev/null
+++ b/patches.fixes/0004-drm-i915-Prevent-a-race-during-I915_GEM_MMAP-ioctl-w.patch
@@ -0,0 +1,65 @@
+From 2e7bd10e05afb866b5fb13eda25095c35d7a27cc Mon Sep 17 00:00:00 2001
+From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
+Date: Thu, 7 Feb 2019 10:54:53 +0200
+Subject: drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
+Git-commit: 2e7bd10e05afb866b5fb13eda25095c35d7a27cc
+Patch-mainline: v5.0-rc7
+References: bsc#1106929
+
+Make sure the underlying VMA in the process address space is the
+same as it was during vm_mmap to avoid applying WC to wrong VMA.
+
+A more long-term solution would be to have vm_mmap_locked variant
+in linux/mmap.h for when caller wants to hold mmap_sem for an
+extended duration.
+
+v2:
+- Refactor the compare function
+
+Fixes: 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
+Reported-by: Adam Zabrocki <adamza@microsoft.com>
+Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
+Cc: <stable@vger.kernel.org> # v4.0+
+Cc: Akash Goel <akash.goel@intel.com>
+Cc: Chris Wilson <chris@chris-wilson.co.uk>
+Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
+Cc: Adam Zabrocki <adamza@microsoft.com>
+Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
+Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> #v1
+Link: https://patchwork.freedesktop.org/patch/msgid/20190207085454.10598-1-joonas.lahtinen@linux.intel.com
+(cherry picked from commit 5c4604e757ba9b193b09768d75a7d2105a5b883f)
+Signed-off-by: Jani Nikula <jani.nikula@intel.com>
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/i915/i915_gem.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/i915/i915_gem.c
++++ b/drivers/gpu/drm/i915/i915_gem.c
+@@ -1708,6 +1708,16 @@ unlock:
+ return ret;
+ }
+
++static inline bool
++__vma_matches(struct vm_area_struct *vma, struct file *filp,
++ unsigned long addr, unsigned long size)
++{
++ if (vma->vm_file != filp)
++ return false;
++
++ return vma->vm_start == addr && (vma->vm_end - vma->vm_start) == size;
++}
++
+ /**
+ * Maps the contents of an object, returning the address it is mapped
+ * into.
+@@ -1760,7 +1770,7 @@ i915_gem_mmap_ioctl(struct drm_device *d
+
+ down_write(&mm->mmap_sem);
+ vma = find_vma(mm, addr);
+- if (vma)
++ if (vma && __vma_matches(vma, obj->filp, addr, args->size))
+ vma->vm_page_prot =
+ pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+ else
diff --git a/series.conf b/series.conf
index e4cc6d8d1d..93aa6b0374 100644
--- a/series.conf
+++ b/series.conf
@@ -24261,6 +24261,7 @@
patches.fixes/0001-gpu-ipu-v3-Fix-i.MX51-CSI-control-registers-offset.patch
patches.fixes/0002-gpu-ipu-v3-Fix-CSI-offsets-for-imx53.patch
patches.fixes/0003-drm-i915-Block-fbdev-HPD-processing-during-suspend.patch
+ patches.fixes/0004-drm-i915-Prevent-a-race-during-I915_GEM_MMAP-ioctl-w.patch
# mkp/scsi 5.0/scsi-fixes
patches.fixes/scsi-target-make-the-pi_prot_format-ConfigFS-path-re.patch