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>] [day] [month] [year] [list]
Date:   Sun, 27 Dec 2020 19:46:44 +0800
From:   Defang Bo <bodefang@....com>
To:     airlied@...ux.ie, daniel@...ll.ch, sumit.semwal@...aro.org
Cc:     alexander.deucher@....com, christian.koenig@....com,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
        linaro-mm-sig@...ts.linaro.org, Defang Bo <bodefang@....com>
Subject: [PATCH] drm/amd:avoid null pointer dereference when dev is not bound

[Why]
Similar to commit<0fa375e6>. If amdgpu_switcheroo_can_switch access
the drm_device when dev is not bound, a null pointer dereference can happen.

[How]
Add sanity checks to prevent it.

Signed-off-by: Defang Bo <bodefang@....com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 37da353..f70e528 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1439,6 +1439,9 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
 static bool amdgpu_switcheroo_can_switch(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
+
+	if (!dev)
+		return false;
 
 	/*
 	* FIXME: open_count is protected by drm_global_mutex but that would lead to
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ