Skip to content

Commit ca8d782

Browse files
icklerodrigovivi
authored andcommitted
drm/i915: Report -EFAULT before pwrite fast path into shmemfs
When pwriting into shmemfs, the fast path pagecache_write does not notice when it is writing to beyond the end of the truncated shmemfs inode. Report -EFAULT directly when we try to use pwrite into the !I915_MADV_WILLNEED object. Fixes: 7c55e2c ("drm/i915: Use pagecache write to prepopulate shmemfs from pwrite-ioctl") Testcase: igt/gem_madvise/dontneed-before-pwrite Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Matthew Auld <matthew.william.auld@gmail.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171016202732.25459-1-chris@chris-wilson.co.uk (cherry picked from commit a6d65e4) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 038daf5 commit ca8d782

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,9 @@ i915_gem_object_pwrite_gtt(struct drm_i915_gem_object *obj,
26572657
if (READ_ONCE(obj->mm.pages))
26582658
return -ENODEV;
26592659

2660+
if (obj->mm.madv != I915_MADV_WILLNEED)
2661+
return -EFAULT;
2662+
26602663
/* Before the pages are instantiated the object is treated as being
26612664
* in the CPU domain. The pages will be clflushed as required before
26622665
* use, and we can freely write into the pages directly. If userspace

0 commit comments

Comments
 (0)