Skip to contentSkip to conversation

drm/amd: add the checking to avoid NULL pointer dereference

PATCH NAK Sharma, Deepak 3 participants 3 messages Nov 22, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: add the checking to avoid NULL pointer dereference

when returned fence is not valid mostly due to userspace ignored previous error causes NULL pointer dereference

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
index 024dfbd87f11..c85bb313e6df 100644
@@ -1420,6 +1420,8 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
 	fence = amdgpu_cs_get_fence(adev, filp, &info->in.fence);
 	if (IS_ERR(fence))
 		return PTR_ERR(fence);
+	if (!fence)
+		return -EINVAL;
 
 	switch (info->in.what) {
 	case AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ:
Signature · 6 lines
2.15.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20181122023610.22058-1-Deepak.Sharma-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 25 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Sharma, Deepak
Sent: Thursday, November 22, 2018 10:37 AM
To: [email protected]
Cc: Sharma, Deepak <[email protected]>
Subject: [PATCH] drm/amd: add the checking to avoid NULL pointer dereference

when returned fence is not valid mostly due to userspace ignored previous error causes NULL pointer dereference

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 024dfbd87f11..c85bb313e6df 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_fence_to_handle_ioctl(struct · line 1425

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -1420,6 +1420,8 @@ int amdgpu_cs_fence_to_handle_ioctl(struct
 drm_device *dev, void *data,
 	fence = amdgpu_cs_get_fence(adev, filp, &info->in.fence);
 	if (IS_ERR(fence))
 		return PTR_ERR(fence);
+	if (!fence)
+		return -EINVAL;

Could you move them into the end of amdgpu_cs_get_fence()? Like:
If (!fence)

	return ERR_PTR(-EINVAL);

Thanks,
-David

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -1
 	switch (info->in.what) {
 	case AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ:
--

2.15.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive

Am 22.11.18 um 03:36 schrieb Sharma, Deepak:

Quoted 2 lines

when returned fence is not valid mostly due to userspace ignored previous error causes NULL pointer dereference

NAK, when the fence is NULL then this means it is already signaled and no longer in the container.

In other words this is a normal case and the following functions need to be able to handle that.

Christian.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 024dfbd87f11..c85bb313e6df 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data, · line 1427

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -1420,6 +1420,8 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
  	fence = amdgpu_cs_get_fence(adev, filp, &info->in.fence);
  	if (IS_ERR(fence))
  		return PTR_ERR(fence);
+	if (!fence)
+		return -EINVAL;
 
  	switch (info->in.what) {
  	case AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx