* [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
@ 2023-06-06 8:34 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-06-06 8:34 UTC (permalink / raw)
To: Jonathan Kim
Cc: Felix Kuehling, Pan, Xinhui, kernel-janitors, amd-gfx,
Daniel Vetter, Alex Deucher, David Airlie, Christian König
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.
Fixes: a42e42c4e3b1 ("drm/amdkfd: prepare per-process debug enable and disable")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
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(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index fc385000c007..6a27b000a246 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
@ 2023-06-06 8:34 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-06-06 8:34 UTC (permalink / raw)
To: Jonathan Kim
Cc: Felix Kuehling, Alex Deucher, Christian König, Pan, Xinhui,
David Airlie, Daniel Vetter, amd-gfx, kernel-janitors
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.
Fixes: a42e42c4e3b1 ("drm/amdkfd: prepare per-process debug enable and disable")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
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(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index fc385000c007..6a27b000a246 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
2023-06-06 8:34 ` Dan Carpenter
@ 2023-06-06 20:17 ` Kim, Jonathan
-1 siblings, 0 replies; 4+ messages in thread
From: Kim, Jonathan @ 2023-06-06 20:17 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kuehling, Felix, Pan, Xinhui, kernel-janitors@vger.kernel.org,
amd-gfx@lists.freedesktop.org, Daniel Vetter, Deucher, Alexander,
David Airlie, Koenig, Christian
[AMD Official Use Only - General]
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Tuesday, June 6, 2023 4:34 AM
> To: Kim, Jonathan <Jonathan.Kim@amd.com>
> Cc: Kuehling, Felix <Felix.Kuehling@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; David
> Airlie <airlied@gmail.com>; Daniel Vetter <daniel@ffwll.ch>; amd-
> gfx@lists.freedesktop.org; kernel-janitors@vger.kernel.org
> Subject: [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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.
>
> Fixes: a42e42c4e3b1 ("drm/amdkfd: prepare per-process debug enable and
> disable")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thank you for catching this.
This looks good to me.
Reviewed-by: Jonathan Kim <jonathan.kim@amd.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index fc385000c007..6a27b000a246 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
@ 2023-06-06 20:17 ` Kim, Jonathan
0 siblings, 0 replies; 4+ messages in thread
From: Kim, Jonathan @ 2023-06-06 20:17 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kuehling, Felix, Deucher, Alexander, Koenig, Christian,
Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org
[AMD Official Use Only - General]
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Tuesday, June 6, 2023 4:34 AM
> To: Kim, Jonathan <Jonathan.Kim@amd.com>
> Cc: Kuehling, Felix <Felix.Kuehling@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; David
> Airlie <airlied@gmail.com>; Daniel Vetter <daniel@ffwll.ch>; amd-
> gfx@lists.freedesktop.org; kernel-janitors@vger.kernel.org
> Subject: [PATCH] drm/amdkfd: potential error pointer dereference in ioctl
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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.
>
> Fixes: a42e42c4e3b1 ("drm/amdkfd: prepare per-process debug enable and
> disable")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thank you for catching this.
This looks good to me.
Reviewed-by: Jonathan Kim <jonathan.kim@amd.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index fc385000c007..6a27b000a246 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-06 20:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 8:34 [PATCH] drm/amdkfd: potential error pointer dereference in ioctl Dan Carpenter
2023-06-06 8:34 ` Dan Carpenter
2023-06-06 20:17 ` Kim, Jonathan
2023-06-06 20:17 ` Kim, Jonathan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.