diff mbox series

drm/i915: Relax mmap VMA check

Message ID 20190305110409.28633-1-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Relax mmap VMA check | expand

Commit Message

Tvrtko Ursulin March 5, 2019, 11:04 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Legacy behaviour was to allow non-page-aligned mmap requests, as does the
linux mmap(2) implementation by virtue of automatically rounding up for
the caller.

To avoid breaking legacy userspace relax the newly introduced fix.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: 5c4604e757ba ("drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Cc: Adam Zabrocki <adamza@microsoft.com>
Cc: 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: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson March 5, 2019, 11:11 a.m. UTC | #1
Quoting Tvrtko Ursulin (2019-03-05 11:04:08)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Legacy behaviour was to allow non-page-aligned mmap requests, as does the
> linux mmap(2) implementation by virtue of automatically rounding up for
> the caller.
> 
> To avoid breaking legacy userspace relax the newly introduced fix.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Fixes: 5c4604e757ba ("drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Cc: Adam Zabrocki <adamza@microsoft.com>
> Cc: 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: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a1ad5e137a97..0196ad97adcb 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1593,7 +1593,8 @@ __vma_matches(struct vm_area_struct *vma, struct file *filp,
>         if (vma->vm_file != filp)
>                 return false;
>  
> -       return vma->vm_start == addr && (vma->vm_end - vma->vm_start) == size;
> +       return vma->vm_start == addr &&
> +              (vma->vm_end - vma->vm_start) == PAGE_ALIGN(size);

Gosh and darnation,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Tvrtko Ursulin March 6, 2019, 11:39 a.m. UTC | #2
On 05/03/2019 11:47, Patchwork wrote:
> == Series Details ==
> 
> Series: drm/i915: Relax mmap VMA check
> URL   : https://patchwork.freedesktop.org/series/57573/
> State : success
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_5703 -> Patchwork_12366
> ====================================================
> 
> Summary
> -------
> 
>    **SUCCESS**
> 
>    No regressions found.
> 
>    External URL: https://patchwork.freedesktop.org/api/1.0/series/57573/revisions/1/mbox/
> 
> Known issues
> ------------
> 
>    Here are the changes found in Patchwork_12366 that come from known issues:
> 
> ### IGT changes ###
> 
> #### Issues hit ####
> 
>    * igt@amdgpu/amd_basic@cs-compute:
>      - fi-kbl-8809g:       NOTRUN -> FAIL [fdo#108094]
> 
>    * igt@amdgpu/amd_basic@cs-sdma:
>      - fi-kbl-7560u:       NOTRUN -> SKIP [fdo#109271] +17
> 
>    * igt@kms_psr@cursor_plane_move:
>      - fi-skl-6260u:       NOTRUN -> SKIP [fdo#109271] +37
> 
>    
> #### Possible fixes ####
> 
>    * igt@amdgpu/amd_basic@userptr:
>      - fi-kbl-8809g:       DMESG-WARN [fdo#108965] -> PASS
> 
>    * igt@i915_module_load@reload-with-fault-injection:
>      - fi-kbl-7560u:       INCOMPLETE [fdo#109831] -> PASS
> 
>    * igt@i915_pm_rpm@basic-pci-d3-state:
>      - fi-byt-j1900:       SKIP [fdo#109271] -> PASS
> 
>    * igt@i915_pm_rpm@basic-rte:
>      - fi-byt-j1900:       FAIL [fdo#108800] -> PASS
> 
>    * igt@i915_pm_rpm@module-reload:
>      - fi-skl-6770hq:      FAIL [fdo#108511] -> PASS
> 
>    * igt@i915_selftest@live_execlists:
>      - fi-apl-guc:         INCOMPLETE [fdo#103927] / [fdo#109720] -> PASS
> 
>    * igt@kms_busy@basic-flip-c:
>      - fi-skl-6770hq:      SKIP [fdo#109271] / [fdo#109278] -> PASS +2
> 
>    * igt@kms_flip@basic-flip-vs-dpms:
>      - fi-skl-6770hq:      SKIP [fdo#109271] -> PASS +33
> 
>    * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
>      - fi-byt-clapper:     FAIL [fdo#103191] / [fdo#107362] -> PASS
> 
>    
>    {name}: This element is suppressed. This means it is ignored when computing
>            the status of the difference (SUCCESS, WARNING, or FAILURE).
> 
>    [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
>    [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
>    [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
>    [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
>    [fdo#108094]: https://bugs.freedesktop.org/show_bug.cgi?id=108094
>    [fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
>    [fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
>    [fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965
>    [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
>    [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
>    [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
>    [fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
>    [fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
>    [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
>    [fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
>    [fdo#109831]: https://bugs.freedesktop.org/show_bug.cgi?id=109831
> 
> 
> Participating hosts (46 -> 40)
> ------------------------------
> 
>    Additional (2): fi-icl-y fi-skl-6260u
>    Missing    (8): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u3 fi-pnv-d510 fi-bdw-samus
> 
> 
> Build changes
> -------------
> 
>      * Linux: CI_DRM_5703 -> Patchwork_12366
> 
>    CI_DRM_5703: 453da75010eb2a0806e75490b86d24beb6fa76a7 @ git://anongit.freedesktop.org/gfx-ci/linux
>    IGT_4870: ed944b45563c694dc6373bc48dc83b8ba7edb19f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
>    Patchwork_12366: 52955dc59640c3c71a522c06ebb4e9a223ae7770 @ git://anongit.freedesktop.org/gfx-ci/linux
> 
> 
> == Linux commits ==
> 
> 52955dc59640 drm/i915: Relax mmap VMA check

Pushed.

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a1ad5e137a97..0196ad97adcb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1593,7 +1593,8 @@  __vma_matches(struct vm_area_struct *vma, struct file *filp,
 	if (vma->vm_file != filp)
 		return false;
 
-	return vma->vm_start == addr && (vma->vm_end - vma->vm_start) == size;
+	return vma->vm_start == addr &&
+	       (vma->vm_end - vma->vm_start) == PAGE_ALIGN(size);
 }
 
 /**