lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  3 Aug 2023 11:23:08 +0200
From:   Lukasz Majczak <lma@...ihalf.com>
To:     David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>
Cc:     Guenter Roeck <linux@...ck-us.net>, upstream@...ihalf.com,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
        Lukasz Majczak <lma@...ihalf.com>, stable@...r.kernel.org
Subject: [PATCH] drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper()

Check mgr->mst_primary, before passing it to
the get_mst_branch_device_by_guid_helper(), otherwise NULL dereference
may occur in the call to memcpy() and cause:

[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

Similar check is done in e.g: drm_dp_mst_topology_get_mstb_validated().

Fixes: 5e93b8208d3c ("drm/dp/mst: move GUID storage from mgr, port to only mst branch")
Cc: <stable@...r.kernel.org> # 4.14+
Signed-off-by: Lukasz Majczak <lma@...ihalf.com>
---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
index ed96cfcfa304..703cd97b1d11 100644
--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
@@ -2595,19 +2595,19 @@ static struct drm_dp_mst_branch *
 drm_dp_get_mst_branch_device_by_guid(struct drm_dp_mst_topology_mgr *mgr,
 				     const uint8_t *guid)
 {
-	struct drm_dp_mst_branch *mstb;
+	struct drm_dp_mst_branch *mstb = NULL;
 	int ret;
 
 	/* find the port by iterating down */
 	mutex_lock(&mgr->lock);
-
-	mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid);
-	if (mstb) {
-		ret = drm_dp_mst_topology_try_get_mstb(mstb);
-		if (!ret)
-			mstb = NULL;
+	if (mgr->mst_primary) {
+		mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid);
+		if (mstb) {
+			ret = drm_dp_mst_topology_try_get_mstb(mstb);
+			if (!ret)
+				mstb = NULL;
+		}
 	}
-
 	mutex_unlock(&mgr->lock);
 	return mstb;
 }
-- 
2.41.0.640.ga95def55d0-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ