1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/gpu/drm/i915/gem
Mastan Katragadda 3886a86e7e drm/i915/gem: add missing boundary check in vm_access
A missing bounds check in vm_access() can lead to an out-of-bounds read
or write in the adjacent memory area, since the len attribute is not
validated before the memcpy later in the function, potentially hitting:

[  183.637831] BUG: unable to handle page fault for address: ffffc90000c86000
[  183.637934] #PF: supervisor read access in kernel mode
[  183.637997] #PF: error_code(0x0000) - not-present page
[  183.638059] PGD 100000067 P4D 100000067 PUD 100258067 PMD 106341067 PTE 0
[  183.638144] Oops: 0000 [#2] PREEMPT SMP NOPTI
[  183.638201] CPU: 3 PID: 1790 Comm: poc Tainted: G      D           5.17.0-rc6-ci-drm-11296+ #1
[  183.638298] Hardware name: Intel Corporation CoffeeLake Client Platform/CoffeeLake H DDR4 RVP, BIOS CNLSFWR1.R00.X208.B00.1905301319 05/30/2019
[  183.638430] RIP: 0010:memcpy_erms+0x6/0x10
[  183.640213] RSP: 0018:ffffc90001763d48 EFLAGS: 00010246
[  183.641117] RAX: ffff888109c14000 RBX: ffff888111bece40 RCX: 0000000000000ffc
[  183.642029] RDX: 0000000000001000 RSI: ffffc90000c86000 RDI: ffff888109c14004
[  183.642946] RBP: 0000000000000ffc R08: 800000000000016b R09: 0000000000000000
[  183.643848] R10: ffffc90000c85000 R11: 0000000000000048 R12: 0000000000001000
[  183.644742] R13: ffff888111bed190 R14: ffff888109c14000 R15: 0000000000001000
[  183.645653] FS:  00007fe5ef807540(0000) GS:ffff88845b380000(0000) knlGS:0000000000000000
[  183.646570] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  183.647481] CR2: ffffc90000c86000 CR3: 000000010ff02006 CR4: 00000000003706e0
[  183.648384] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  183.649271] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  183.650142] Call Trace:
[  183.650988]  <TASK>
[  183.651793]  vm_access+0x1f0/0x2a0 [i915]
[  183.652726]  __access_remote_vm+0x224/0x380
[  183.653561]  mem_rw.isra.0+0xf9/0x190
[  183.654402]  vfs_read+0x9d/0x1b0
[  183.655238]  ksys_read+0x63/0xe0
[  183.656065]  do_syscall_64+0x38/0xc0
[  183.656882]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  183.657663] RIP: 0033:0x7fe5ef725142
[  183.659351] RSP: 002b:00007ffe1e81c7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[  183.660227] RAX: ffffffffffffffda RBX: 0000557055dfb780 RCX: 00007fe5ef725142
[  183.661104] RDX: 0000000000001000 RSI: 00007ffe1e81d880 RDI: 0000000000000005
[  183.661972] RBP: 00007ffe1e81e890 R08: 0000000000000030 R09: 0000000000000046
[  183.662832] R10: 0000557055dfc2e0 R11: 0000000000000246 R12: 0000557055dfb1c0
[  183.663691] R13: 00007ffe1e81e980 R14: 0000000000000000 R15: 0000000000000000

Changes since v1:
     - Updated if condition with range_overflows_t [Chris Wilson]

Fixes: 9f909e215f ("drm/i915: Implement vm_ops->access for gdb access into mmaps")
Signed-off-by: Mastan Katragadda <mastanx.katragadda@intel.com>
Suggested-by: Adam Zabrocki <adamza@microsoft.com>
Reported-by: Jackson Cody <cody.jackson@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jon Bloomfield <jon.bloomfield@intel.com>
Cc: Sudeep Dutt <sudeep.dutt@intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
[mauld: tidy up the commit message and add Cc: stable]
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220303060428.1668844-1-mastanx.katragadda@intel.com
(cherry picked from commit 661412e301)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2022-03-14 10:07:20 +02:00
..
selftests drm/i915/xehp: CCS should use RCS setup functions 2022-03-02 06:45:19 -08:00
i915_gem_busy.c drm/i915: use the new iterator in i915_gem_busy_ioctl v2 2021-11-17 14:23:09 +01:00
i915_gem_clflush.c drm/i915: don't include drm_cache.h in i915_drv.h 2022-02-14 13:19:37 +02:00
i915_gem_clflush.h
i915_gem_context.c drm/i915/xehp: Don't support parallel submission on compute / render 2022-03-02 06:52:42 -08:00
i915_gem_context.h drm/i915/gem: Use to_gt() helper for GGTT accesses 2022-01-05 10:43:36 -08:00
i915_gem_context_types.h drm/i915/guc: Connect UAPI to GuC multi-lrc interface 2021-10-15 10:45:50 -07:00
i915_gem_create.c drm/i915: include some drm headers only where needed 2022-02-14 13:39:54 +02:00
i915_gem_create.h drm/i915: split out gem/i915_gem_create.h from i915_drv.h 2022-02-11 14:43:28 +02:00
i915_gem_dmabuf.c drm/i915: split out gem/i915_gem_dmabuf.h from i915_drv.h 2022-02-11 13:50:37 +02:00
i915_gem_dmabuf.h drm/i915: split out gem/i915_gem_dmabuf.h from i915_drv.h 2022-02-11 13:50:37 +02:00
i915_gem_domain.c drm/i915: split out gem/i915_gem_domain.h from i915_drv.h 2022-02-14 11:25:52 +02:00
i915_gem_domain.h drm/i915: split out gem/i915_gem_domain.h from i915_drv.h 2022-02-14 11:25:52 +02:00
i915_gem_execbuffer.c Merge tag 'drm-intel-gt-next-2022-02-17' of git://anongit.freedesktop.org/drm/drm-intel into drm-intel-next 2022-02-23 15:03:51 -05:00
i915_gem_internal.c drm/i915: split out i915_gem_internal.h from i915_drv.h 2022-02-11 12:52:50 +02:00
i915_gem_internal.h drm/i915: split out i915_gem_internal.h from i915_drv.h 2022-02-11 12:52:50 +02:00
i915_gem_ioctls.h drm/i915/uapi: introduce drm_i915_gem_create_ext 2021-05-04 10:58:56 +01:00
i915_gem_lmem.c drm/i915/gem: Fix a lockdep warning the __i915_gem_is_lmem() function 2021-09-24 08:17:39 +02:00
i915_gem_lmem.h drm/i915/guc: put all guc objects in lmem when available 2021-09-20 12:35:41 -07:00
i915_gem_mman.c drm/i915/gem: add missing boundary check in vm_access 2022-03-14 10:07:20 +02:00
i915_gem_mman.h drm/i915/gem: Only revoke mmap handlers if active 2020-07-02 20:46:08 +01:00
i915_gem_object.c drm/i915: Clarify vma lifetime 2022-02-28 15:04:53 +01:00
i915_gem_object.h drm/i915: Asynchronous migration selftest 2022-01-11 10:54:11 +01:00
i915_gem_object_types.h drm/i915: add I915_BO_ALLOC_GPU_ONLY 2022-02-28 08:47:34 +00:00
i915_gem_pages.c drm/i915: add I915_BO_ALLOC_GPU_ONLY 2022-02-28 08:47:34 +00:00
i915_gem_phys.c drm/i915/gem: Use to_gt() helper 2021-12-17 21:50:32 -08:00
i915_gem_pm.c Merge tag 'drm-intel-gt-next-2022-02-17' of git://anongit.freedesktop.org/drm/drm-intel into drm-intel-next 2022-02-23 15:03:51 -05:00
i915_gem_pm.h drm/i915 Implement LMEM backup and restore for suspend / resume 2021-09-24 08:19:11 +02:00
i915_gem_region.c drm/i915: add I915_BO_ALLOC_GPU_ONLY 2022-02-28 08:47:34 +00:00
i915_gem_region.h drm/i915/gem: Implement a function to process all gem objects of a region 2021-09-24 08:19:09 +02:00
i915_gem_shmem.c drm/i915: add io_size plumbing 2022-02-28 08:47:27 +00:00
i915_gem_shrinker.c drm/i915: clean up shrinker_release_pages 2022-01-10 10:49:50 +00:00
i915_gem_shrinker.h drm/i915: Finally remove obj->mm.lock. 2021-03-24 17:47:20 +01:00
i915_gem_stolen.c drm/i915: add io_size plumbing 2022-02-28 08:47:27 +00:00
i915_gem_stolen.h drm/i915/ttm Initialize the ttm device and memory managers 2021-06-02 13:21:24 +01:00
i915_gem_throttle.c drm/i915: split out i915_file_private.h from i915_drv.h 2022-02-14 13:16:28 +02:00
i915_gem_tiling.c Merge tag 'drm-intel-gt-next-2022-02-17' of git://anongit.freedesktop.org/drm/drm-intel into drm-intel-next 2022-02-23 15:03:51 -05:00
i915_gem_tiling.h drm/i915: split out gem/i915_gem_tiling.h from i915_drv.h 2022-01-10 15:43:23 +02:00
i915_gem_ttm.c drm/i915/ttm: mappable migration on fault 2022-03-01 08:50:46 +00:00
i915_gem_ttm.h drm/i915/ttm: Implement asynchronous TTM moves 2021-11-25 09:36:19 +01:00
i915_gem_ttm_move.c drm/i915/ttm: Return some errors instead of trying memcpy move 2022-02-01 14:10:12 +01:00
i915_gem_ttm_move.h drm/i915: Break out the i915_deps utility 2021-12-22 08:52:57 +01:00
i915_gem_ttm_pm.c drm/i915/ttm: Update i915_gem_obj_copy_ttm() to be asynchronous 2021-11-25 09:36:20 +01:00
i915_gem_ttm_pm.h drm/i915 Implement LMEM backup and restore for suspend / resume 2021-09-24 08:19:11 +02:00
i915_gem_userptr.c Merge drm/drm-next into drm-intel-next 2022-01-31 13:19:33 -05:00
i915_gem_userptr.h drm/i915: split out gem/i915_gem_userptr.h from i915_drv.h 2022-01-10 15:43:19 +02:00
i915_gem_wait.c drm/i915: Remove dma_resv_prune 2021-11-30 15:59:17 +01:00
i915_gemfs.c drm/i915: Use per device iommu check 2021-12-01 09:21:47 +00:00
i915_gemfs.h