[Intel-gfx] [PATCH 3/4] drm/i915: Implement vm_ops->access for gdb access into mmaps

Matthew Auld matthew.auld at intel.com
Fri May 1 14:43:03 UTC 2020


On 01/05/2020 09:42, Chris Wilson wrote:
> gdb uses ptrace() to peek and poke bytes of the target's address space.
> The driver must implement an vm_ops->access() handler or else gdb will
> be unable to inspect the pointer and report it as out-of-bounds.
> Worse than useless as it causes immediate suspicion of the valid GTT
> pointer, distracting the poor programmer trying to find his bug.
> 
> Testcase: igt/gem_mmap_gtt/ptrace
> Testcase: igt/gem_mmap_offset/ptrace
> Suggested-by: Kristian H. Kristensen <hoegsberg at google.com>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Maciej Patelczyk <maciej.patelczyk at intel.com>
> Cc: Kristian H. Kristensen <hoegsberg at google.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_mman.c      |  31 +++++
>   .../drm/i915/gem/selftests/i915_gem_mman.c    | 124 ++++++++++++++++++
>   2 files changed, 155 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index b39c24dae64e..aef917b7f168 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -396,6 +396,35 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
>   	return i915_error_to_vmf_fault(ret);
>   }
>   
> +static int
> +vm_access(struct vm_area_struct *area, unsigned long addr,
> +	  void *buf, int len, int write)
> +{
> +	struct i915_mmap_offset *mmo = area->vm_private_data;
> +	struct drm_i915_gem_object *obj = mmo->obj;
> +	void *vaddr;
> +

What's the story with object_is_readonly and write=true here? Shouldn't 
we reject, or what?

Reviewed-by: Matthew Auld <matthew.auld at intel.com>


More information about the Intel-gfx mailing list