linux/drivers/gpu/drm
Maarten Lankhorst 5279fc7724 drm/i915: Fix out-of-bounds array access in bdw_load_gamma_lut
bdw_load_gamma_lut is writing beyond the array to the maximum value.
The intend of the function is to clamp values > 1 to 1, so write
the intended color to the max register.

This fixes the following KASAN warning:

[  197.020857] [IGT] kms_pipe_color: executing
[  197.063434] [IGT] kms_pipe_color: starting subtest ctm-0-25-pipe0
[  197.078989] ==================================================================
[  197.079127] BUG: KASAN: slab-out-of-bounds in bdw_load_gamma_lut.isra.2+0x3b9/0x570 [i915]
[  197.079188] Read of size 2 at addr ffff8800d38db150 by task kms_pipe_color/1839
[  197.079208] CPU: 2 PID: 1839 Comm: kms_pipe_color Tainted: G     U 4.13.0-rc1-patser+ #5211
[  197.079215] Hardware name: NUC5i7RYB, BIOS RYBDWi35.86A.0246.2015.0309.1355 03/09/2015
[  197.079220] Call Trace:
[  197.079230]  dump_stack+0x68/0x9e
[  197.079239]  print_address_description+0x6f/0x250
[  197.079251]  kasan_report+0x216/0x370
[  197.079374]  ? bdw_load_gamma_lut.isra.2+0x3b9/0x570 [i915]
[  197.079451]  ? gen8_write16+0x4e0/0x4e0 [i915]
[  197.079460]  __asan_report_load2_noabort+0x14/0x20
[  197.079535]  bdw_load_gamma_lut.isra.2+0x3b9/0x570 [i915]
[  197.079612]  broadwell_load_luts+0x1df/0x550 [i915]
[  197.079690]  intel_color_load_luts+0x7b/0x80 [i915]
[  197.079764]  intel_begin_crtc_commit+0x138/0x760 [i915]
[  197.079783]  drm_atomic_helper_commit_planes_on_crtc+0x1a3/0x820 [drm_kms_helper]
[  197.079859]  ? intel_pre_plane_update+0x571/0x580 [i915]
[  197.079937]  intel_update_crtc+0x238/0x330 [i915]
[  197.080016]  intel_update_crtcs+0x10f/0x210 [i915]
[  197.080092]  intel_atomic_commit_tail+0x1552/0x3340 [i915]
[  197.080101]  ? _raw_spin_unlock+0x3c/0x40
[  197.080110]  ? __queue_work+0xb40/0xbf0
[  197.080188]  ? skl_update_crtcs+0xc00/0xc00 [i915]
[  197.080195]  ? trace_hardirqs_on+0xd/0x10
[  197.080269]  ? intel_atomic_commit_ready+0x128/0x13c [i915]
[  197.080329]  ? __i915_sw_fence_complete+0x5b8/0x6d0 [i915]
[  197.080336]  ? debug_object_activate+0x39e/0x580
[  197.080397]  ? i915_sw_fence_await+0x30/0x30 [i915]
[  197.080409]  ? __might_sleep+0x15b/0x180
[  197.080483]  intel_atomic_commit+0x944/0xa70 [i915]
[  197.080490]  ? refcount_dec_and_test+0x11/0x20
[  197.080567]  ? intel_atomic_commit_tail+0x3340/0x3340 [i915]
[  197.080597]  ? drm_atomic_crtc_set_property+0x303/0x580 [drm]
[  197.080674]  ? intel_atomic_commit_tail+0x3340/0x3340 [i915]
[  197.080704]  drm_atomic_commit+0xd7/0xe0 [drm]
[  197.080722]  drm_atomic_helper_crtc_set_property+0xec/0x130 [drm_kms_helper]
[  197.080749]  drm_mode_crtc_set_obj_prop+0x7d/0xb0 [drm]
[  197.080775]  drm_mode_obj_set_property_ioctl+0x50b/0x5d0 [drm]
[  197.080783]  ? __might_fault+0x104/0x180
[  197.080809]  ? drm_mode_obj_find_prop_id+0x160/0x160 [drm]
[  197.080838]  ? drm_mode_obj_find_prop_id+0x160/0x160 [drm]
[  197.080861]  drm_ioctl_kernel+0x154/0x1a0 [drm]
[  197.080885]  drm_ioctl+0x624/0x8f0 [drm]
[  197.080910]  ? drm_mode_obj_find_prop_id+0x160/0x160 [drm]
[  197.080934]  ? drm_getunique+0x210/0x210 [drm]
[  197.080943]  ? __handle_mm_fault+0x1bd0/0x1ce0
[  197.080949]  ? lock_downgrade+0x610/0x610
[  197.080957]  ? __lru_cache_add+0x15a/0x180
[  197.080967]  do_vfs_ioctl+0xd92/0xe40
[  197.080975]  ? ioctl_preallocate+0x1b0/0x1b0
[  197.080982]  ? selinux_capable+0x20/0x20
[  197.080991]  ? __do_page_fault+0x7b7/0x9a0
[  197.080997]  ? lock_downgrade+0x5bb/0x610
[  197.081007]  ? security_file_ioctl+0x57/0x90
[  197.081016]  SyS_ioctl+0x4e/0x80
[  197.081024]  entry_SYSCALL_64_fastpath+0x18/0xad
[  197.081030] RIP: 0033:0x7f61f287a987
[  197.081035] RSP: 002b:00007fff7d44d188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[  197.081043] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f61f287a987
[  197.081048] RDX: 00007fff7d44d1c0 RSI: 00000000c01864ba RDI: 0000000000000003
[  197.081053] RBP: 00007f61f2b3eb00 R08: 0000000000000059 R09: 0000000000000000
[  197.081058] R10: 0000002ea5c4a290 R11: 0000000000000246 R12: 00007f61f2b3eb58
[  197.081063] R13: 0000000000001010 R14: 00007f61f2b3eb58 R15: 0000000000002702

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101659
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reported-by: Martin Peres <martin.peres@linux.intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
Fixes: 82cf435b31 ("drm/i915: Implement color management on bdw/skl/bxt/kbl")
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Kiran S Kumar <kiran.s.kumar@intel.com>
Cc: Kausal Malladi <kausalmalladi@gmail.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.7+
Link: https://patchwork.freedesktop.org/patch/msgid/20170724091431.24251-1-maarten.lankhorst@linux.intel.com
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 09a92bc877)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
2017-08-07 11:28:23 +03:00
..
amd drm/amdgpu: Use list_del_init in amdgpu_mn_unregister 2017-08-02 14:29:58 -04:00
arc drm/arcgpu: Drop drm_vblank_cleanup 2017-05-31 10:57:08 +02:00
arm drm/arm: hdlcd: remove unused variables 2017-06-21 10:51:26 +01:00
armada main drm pull for v4.13 2017-07-09 18:48:37 -07:00
ast drm/ast: fix include notation and remove -Iinclude/drm flag 2017-05-16 17:17:51 +02:00
atmel-hlcdc Merge tag 'drm-misc-next-2017-06-15' of git://anongit.freedesktop.org/git/drm-misc into drm-next 2017-06-16 09:33:43 +10:00
bochs drm/bochs: fix include notation and remove -Iinclude/drm flag 2017-05-16 17:18:23 +02:00
bridge i915, amd and some core fixes + mediatek color support 2017-07-13 11:26:18 -07:00
cirrus drm/cirrus: fix include notation and remove -Iinclude/drm flag 2017-05-16 17:18:56 +02:00
etnaviv main drm pull for v4.13 2017-07-09 18:48:37 -07:00
exynos drm: exynos: mark pm functions as __maybe_unused 2017-07-27 09:24:03 +09:00
fsl-dcu drm/fsl-dcu: use new drm_atomic_helper_shutdown 2017-06-08 14:59:14 -07:00
gma500 Linux 4.12-rc3 2017-05-30 15:54:15 +10:00
hisilicon Linux 4.12-rc5 2017-06-16 13:58:27 +10:00
i2c drm/i2c: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:13:04 +02:00
i810 drm/i810: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:12:57 +02:00
i915 drm/i915: Fix out-of-bounds array access in bdw_load_gamma_lut 2017-08-07 11:28:23 +03:00
imx imx-drm: fix parallel display regression and typo in plane format list 2017-07-21 14:04:44 +10:00
lib drm: Add a simple generator of random permutations 2016-12-27 12:34:00 +01:00
mediatek drm/mediatek: separate color module to fixup error memory reallocation 2017-06-27 17:34:53 +08:00
meson Linux 4.12-rc5 2017-06-16 13:58:27 +10:00
mga main drm pull for v4.13 2017-07-09 18:48:37 -07:00
mgag200 Linux 4.12-rc7 2017-06-27 08:28:30 +10:00
msm drm/msm: Fix potential buffer overflow issue 2017-06-19 19:58:57 -04:00
mxsfb drm: mxsfb_crtc: Reset the eLCDIF controller 2017-06-15 14:26:24 -04:00
nouveau drm/nouveau/bar/gf100: fix access to upper half of BAR2 2017-07-25 15:30:27 +10:00
omapdrm drm/omap: fix tiled buffer stride calculations 2017-06-02 11:09:34 +03:00
panel drm/panel: s6e3ha2: Add support for s6e3hf2 panel on TM2e board 2017-06-14 20:18:22 +02:00
pl111 drm/pl111: Fix offset calculation for the primary plane. 2017-06-07 11:50:00 -07:00
qxl Linux 4.12-rc3 2017-05-30 15:54:15 +10:00
r128 drm/r128: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:13:23 +02:00
radeon drm/radeon: Remove initialization of shared_resources.num_mec 2017-07-13 20:21:55 -05:00
rcar-du drm: rcar-du: Map memory through the VSP device 2017-06-09 12:25:38 +01:00
rockchip drm/rockchip: fix Kconfig dependencies 2017-07-24 09:53:09 +08:00
savage drm/savage: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:13:34 +02:00
selftests drm/mm: Split up long running selftests with cond_resched() 2017-05-04 08:11:46 +02:00
shmobile drm: Add acquire ctx parameter to ->page_flip(_target) 2017-03-29 09:50:38 +02:00
sis drm/sis: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:13:40 +02:00
sti Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2017-05-18 09:24:30 -04:00
stm drm/stm: Drop drm_vblank_cleanup 2017-05-31 10:48:58 +02:00
sun4i sun4i-drm changes for 4.13 2017-06-16 10:02:35 +10:00
tdfx drm/tdfx: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:13:47 +02:00
tegra Linux 4.12-rc7 2017-06-27 08:28:30 +10:00
tilcdc drm/tilcdc: fix include notation and remove -Iinclude/drm flag 2017-05-17 14:36:49 +02:00
tinydrm drm: Use vsnprintf extension %ph 2017-05-31 10:30:38 +02:00
ttm drm/ttm: Fix use-after-free in ttm_bo_clean_mm 2017-07-03 16:25:43 -04:00
udl drm: drop drm_[cm]alloc* helpers 2017-05-18 17:22:39 +02:00
vc4 drm/vc4: Fix VBLANK handling in crtc->enable() path 2017-07-14 13:19:48 -07:00
vgem drm/vgem: Fix return value check in vgem_init() 2017-05-22 09:47:34 +02:00
via drm/via: remove unneeded -Iinclude/drm compiler flag 2017-05-18 07:14:05 +02:00
virtio drm: Remove drm_device->virtdev 2017-05-29 20:57:25 +02:00
vmwgfx Merge branch 'drm-vmwgfx-fixes' of git://people.freedesktop.org/~syeh/repos_linux into drm-fixes 2017-07-24 15:57:28 +10:00
zte drm: zte: use devm_of_platform_populate() 2017-06-05 09:57:14 +08:00
ati_pcigart.c
drm_agpsupport.c drm/i810: drop device_is_agp callback 2017-01-26 10:44:43 +01:00
drm_atomic_helper.c Linux 4.12-rc5 2017-06-16 13:58:27 +10:00
drm_atomic.c drm: Reduce scope of 'state' variable 2017-06-15 14:26:02 -04:00
drm_auth.c drm/core: Use recommened kerneldoc for struct member refs 2017-01-25 16:22:42 +01:00
drm_blend.c drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI 2017-05-22 09:49:48 +02:00
drm_bridge.c drm: Introduce drm_bridge_mode_valid() 2017-05-30 08:37:50 +02:00
drm_bufs.c switch compat_drm_mapbufs() to drm_ioctl_kernel() 2017-07-04 13:16:26 -04:00
drm_cache.c gpu: drm: core: Convert printk(KERN_<LEVEL> to pr_<level> 2017-02-28 14:32:19 +01:00
drm_color_mgmt.c drm/doc: Interlink color manager docs better 2017-04-18 08:56:29 +02:00
drm_connector.c Linux 4.12-rc7 2017-06-27 08:28:30 +10:00
drm_context.c
drm_crtc_helper_internal.h drm: Add drm_{crtc/encoder/connector}_mode_valid() 2017-05-30 08:37:24 +02:00
drm_crtc_helper.c drm: Add acquire ctx parameter to ->set_config 2017-03-29 09:56:25 +02:00
drm_crtc_internal.h drm: extract legacy framebuffer remove 2017-04-06 10:22:43 +02:00
drm_crtc.c drm: Take mode_config.mutex in setcrtc ioctl 2017-04-06 22:49:50 +02:00
drm_debugfs_crc.c Revert "drm: Don't allow interruptions when opening debugfs/crc" 2017-04-07 16:18:28 -04:00
drm_debugfs.c drm/debugfs: Add kerneldoc 2017-03-24 09:36:06 +01:00
drm_dma.c
drm_dp_aux_dev.c drm_dp_aux_dev: switch to read_iter/write_iter 2017-07-08 20:51:46 -04:00
drm_dp_dual_mode_helper.c drm: Add name for DRM_DP_DUAL_MODE_LSPCON 2017-02-23 11:06:12 -05:00
drm_dp_helper.c drm/dp: Don't trust drm_dp_downstream_id() 2017-07-21 17:45:26 +03:00
drm_dp_mst_topology.c drm/mst: Avoid processing partially received up/down message transactions 2017-07-20 10:20:31 +02:00
drm_drv.c drm: Fix oops + Xserver hang when unplugging USB drm devices 2017-06-02 11:09:35 -04:00
drm_dumb_buffers.c drm/kms-core: Use recommened kerneldoc for struct member refs 2017-01-25 16:30:34 +01:00
drm_edid_load.c drm: move edid property update and add modes out of edid firmware loader 2017-02-21 15:41:24 +02:00
drm_edid.c drm/edid: Add 10 bpc quirk for LGD 764 panel in HP zBook 17 G2 2017-05-02 10:37:45 +02:00
drm_encoder_slave.c drm/kms-core: Use recommened kerneldoc for struct member refs 2017-01-25 16:30:34 +01:00
drm_encoder.c drm: Rename connector list iterator API 2017-02-28 16:16:48 +01:00
drm_fb_cma_helper.c drm/cma-helper: Return ENOENT for "no such gem obj" 2017-04-18 17:57:37 +02:00
drm_fb_helper.c drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI 2017-05-22 09:49:48 +02:00
drm_file.c drm: introduce sync objects (v4) 2017-06-14 12:10:22 +10:00
drm_flip_work.c
drm_fourcc.c Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux into drm-misc-next 2017-03-23 08:15:55 +01:00
drm_framebuffer.c drm/atomic: Add missing drm_atomic_state_clear to atomic_remove_fb 2017-07-03 10:31:37 +02:00
drm_gem_cma_helper.c Pointer for Markus's image conversion work. 2017-03-14 15:07:33 +01:00
drm_gem.c drm: drop drm_[cm]alloc* helpers 2017-05-18 17:22:39 +02:00
drm_global.c drm: Update TTM initialization documentation 2016-12-30 12:52:10 +01:00
drm_hashtab.c
drm_info.c locking/atomic, kref: Add kref_read() 2017-01-14 11:37:18 +01:00
drm_internal.h main drm pull for v4.13 2017-07-09 18:48:37 -07:00
drm_ioc32.c drm: Add missing field copy in compat_drm_version 2017-07-13 11:25:04 -07:00
drm_ioctl.c main drm pull for v4.13 2017-07-09 18:48:37 -07:00
drm_irq.c drm/doc: Polish irq helper documentation 2017-06-01 08:02:14 +02:00
drm_kms_helper_common.c drm: Remove drmP.h include from drm_kms_helper_common.c 2017-03-09 16:18:02 +01:00
drm_legacy.h switch compat_drm_mapbufs() to drm_ioctl_kernel() 2017-07-04 13:16:26 -04:00
drm_lock.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
drm_memory.c
drm_mipi_dsi.c
drm_mm.c drm: Micro-optimise drm_mm_for_each_node_in_range() 2017-02-06 16:57:37 +01:00
drm_mode_config.c drm: Rename connector list iterator API 2017-02-28 16:16:48 +01:00
drm_mode_object.c Pointer for Markus's image conversion work. 2017-03-14 15:07:33 +01:00
drm_modes.c drm: Rename drm_mode_object_get() 2017-02-28 16:14:53 +01:00
drm_modeset_helper.c drm: Add mode_config .get_format_info() hook 2017-03-22 19:45:00 +02:00
drm_modeset_lock.c drm: Remove drm_modeset_legacy_acquire_ctx and crtc->acquire_ctx 2017-04-05 09:26:45 +02:00
drm_of.c drm: of: introduce drm_of_find_panel_or_bridge 2017-04-06 17:00:27 -04:00
drm_panel.c drm/panel: Constify device node argument to of_drm_find_panel() 2017-01-04 08:30:37 +01:00
drm_pci.c drm: Extract drm_pci.h 2017-03-09 16:18:02 +01:00
drm_plane_helper.c drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI 2017-05-22 09:49:48 +02:00
drm_plane.c drm: Fix deadlock retry loop in page_flip_ioctl 2017-05-23 09:39:14 +02:00
drm_prime.c drm/prime: Introduce drm_gem_prime_import_dev 2017-05-08 09:39:13 +02:00
drm_print.c drm: drm_printer: add __printf validation 2017-02-26 21:43:08 +01:00
drm_probe_helper.c drm: Use new mode_valid() helpers in connector probe helper 2017-05-30 08:37:50 +02:00
drm_property.c drm: Fix get_property logic fumble 2017-04-12 18:11:32 +02:00
drm_rect.c drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI 2017-05-22 09:49:48 +02:00
drm_scatter.c
drm_scdc_helper.c drm/edid: detect SCDC support in HF-VSDB 2017-03-21 10:15:56 +02:00
drm_simple_kms_helper.c drm: Clarify the role of plane_state argument to drm_simple update(). 2017-03-30 12:02:00 -07:00
drm_syncobj.c drm: Remove unused drm_file parameter to drm_syncobj_replace_fence() 2017-07-06 15:53:00 +10:00
drm_sysfs.c drm: Consolidate and document sysfs support 2017-04-04 20:47:54 +02:00
drm_trace_points.c
drm_trace.h drm: Remove drm_pending_event->pid 2017-03-14 14:38:33 +01:00
drm_vblank.c drm: vblank: Fix vblank timestamp update 2017-06-29 14:40:47 +02:00
drm_vm.c drm: remove unnecessary fault wrappers 2017-02-24 17:46:55 -08:00
drm_vma_manager.c drm: Improve drm_mm search (and fix topdown allocation) with rbtrees 2017-02-03 11:10:32 +01:00
Kconfig drm/pl111: Initial drm/kms driver for pl111 2017-05-08 12:24:06 -07:00
Makefile Merge tag 'drm-misc-next-2017-06-15' of git://anongit.freedesktop.org/git/drm-misc into drm-next 2017-06-16 09:33:43 +10:00