bianbu-linux-6.6/drivers/gpu/drm/display
Lukasz Majczak 3d887d5124 drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper()
As drm_dp_get_mst_branch_device_by_guid() is called from
drm_dp_get_mst_branch_device_by_guid(), mstb parameter has to be checked,
otherwise NULL dereference may occur in the call to
the memcpy() and cause following:

[12579.365869] BUG: kernel NULL pointer dereference, address: 0000000000000049
[12579.365878] #PF: supervisor read access in kernel mode
[12579.365880] #PF: error_code(0x0000) - not-present page
[12579.365882] PGD 0 P4D 0
[12579.365887] Oops: 0000 [#1] PREEMPT SMP NOPTI
...
[12579.365895] Workqueue: events_long drm_dp_mst_up_req_work
[12579.365899] RIP: 0010:memcmp+0xb/0x29
[12579.365921] Call Trace:
[12579.365927] get_mst_branch_device_by_guid_helper+0x22/0x64
[12579.365930] drm_dp_mst_up_req_work+0x137/0x416
[12579.365933] process_one_work+0x1d0/0x419
[12579.365935] worker_thread+0x11a/0x289
[12579.365938] kthread+0x13e/0x14f
[12579.365941] ? process_one_work+0x419/0x419
[12579.365943] ? kthread_blkcg+0x31/0x31
[12579.365946] ret_from_fork+0x1f/0x30

As get_mst_branch_device_by_guid_helper() is recursive, moving condition
to the first line allow to remove a similar one for step over of NULL elements
inside a loop.

Fixes: 5e93b8208d ("drm/dp/mst: move GUID storage from mgr, port to only mst branch")
Cc: <stable@vger.kernel.org> # 4.14+
Signed-off-by: Lukasz Majczak <lma@semihalf.com>
Reviewed-by: Radoslaw Biernacki <rad@chromium.org>
Signed-off-by: Manasi Navare <navaremanasi@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230922063410.23626-1-lma@semihalf.com
2023-10-19 20:04:59 +00:00
..
drm_display_helper_mod.c
drm_dp_aux_bus.c driver core: make struct device_type.uevent() take a const * 2023-01-27 13:45:36 +01:00
drm_dp_aux_dev.c driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
drm_dp_cec.c
drm_dp_dual_mode_helper.c drm/display: Don't assume dual mode adaptors support i2c sub-addressing 2022-11-15 23:31:02 +02:00
drm_dp_helper.c drm/display/dp_mst: Replace all non-returning strlcpy with strscpy 2023-06-01 07:07:36 -07:00
drm_dp_helper_internal.h
drm_dp_mst_topology.c drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper() 2023-10-19 20:04:59 +00:00
drm_dp_mst_topology_internal.h
drm_dsc_helper.c drm/display/dsc: Add drm_dsc_get_bpp_int helper 2023-06-15 12:58:56 +03:00
drm_hdcp_helper.c drm/sysfs: rename drm_sysfs_connector_status_event() 2023-06-23 15:54:00 +02:00
drm_hdmi_helper.c drm/display: Don't block HDR_OUTPUT_METADATA on unknown EOTF 2023-03-07 15:54:18 -05:00
drm_scdc_helper.c drm/scdc-helper: Pimp SCDC debugs 2023-04-06 01:30:12 +03:00
Kconfig drm/display: Fix build error without CONFIG_OF 2022-06-23 16:18:02 +02:00
Makefile drm: split build lists one per line and sort 2022-10-12 17:00:05 +03:00