drm/amdkfd: potential error pointer dereference in ioctl
Subsystems (4)
PATCH 1/1 drm/amdkfd: potential error pointer dereference in ioctl
The "target" either comes from kfd_create_process() which returns error pointers on error or kfd_lookup_process_by_pid() which returns NULL on error. So we need to check for both types of errors.
---
I'm not sure how to compile this code or why I'm seeing this warning again after two years... Very strange.
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -2
@@ -2920,9 +2920,9 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v target =kfd_lookup_process_by_pid (pid); } -if (!target) { +if (IS_ERR_OR_NULL (target)) {pr_debug ("Cannot find process PID %i to debug\n" , args->pid); - r = -ESRCH ; + r = target ?PTR_ERR (target) : -ESRCH ; goto out; }
Signature · 1 line
2.39.2
[AMD Official Use Only - General]
Quoted 15 lines
-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Tuesday, June 6, 2023 4:34 AM
To: Kim, Jonathan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; amd- [email protected]; [email protected]
Subject: [PATCH] drm/amdkfd: potential error pointer dereference in ioctlCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 7 lines
The "target" either comes from
kfd_create_process()which returns error pointers on error orkfd_lookup_process_by_pid()which returns NULL on error. So we need to check for both types of errors.Fixes a42e42c4e3b1 ("drm/amdkfd: prepare per-process debug enable anddisable")
Signed-off-by Dan Carpenter <[email protected]>
Thank you for catching this.
This looks good to me.
Quoted 27 lines
---
I'm not sure how to compile this code or why I'm seeing this warning again after two years... Very strange.drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2
-3@@ -2920,9 +2920,9 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v target =kfd_lookup_process_by_pid (pid); } -if (!target) { +if (IS_ERR_OR_NULL (target)) {pr_debug ("Cannot find process PID %i to debug\n" , args->pid); - r = -ESRCH ; + r = target ?PTR_ERR (target) : -ESRCH ; goto out; } --2.39.2