* [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo
@ 2025-02-06 13:47 Dheeraj Reddy Jonnalagadda
2025-02-06 16:33 ` Cavitt, Jonathan
2025-02-06 16:58 ` Lucas De Marchi
0 siblings, 2 replies; 3+ messages in thread
From: Dheeraj Reddy Jonnalagadda @ 2025-02-06 13:47 UTC (permalink / raw)
To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi
Cc: airlied, simona, intel-xe, dri-devel, linux-kernel,
Dheeraj Reddy Jonnalagadda
xe_vm_bind_kernel_bo() declares the variable fence without initializing
it. If an error occurs before fence is assigned a valid value, the
function may return an uninitialized pointer.
Specifically, this can happen if:
- vm_bind_ioctl_ops_create() fails, leading to release_vm_lock error
path
Initialize fence to NULL at declaration.
Fixes: dcdd6b84d9ac ("drm/xe/pxp: Allocate PXP execution resources")
Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
---
drivers/gpu/drm/xe/xe_vm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index d664f2e418b2..b6ca53ede904 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -3184,7 +3184,7 @@ struct dma_fence *xe_vm_bind_kernel_bo(struct xe_vm *vm, struct xe_bo *bo,
{
struct xe_vma_ops vops;
struct drm_gpuva_ops *ops = NULL;
- struct dma_fence *fence;
+ struct dma_fence *fence = NULL;
int err;
xe_bo_get(bo);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo
2025-02-06 13:47 [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo Dheeraj Reddy Jonnalagadda
@ 2025-02-06 16:33 ` Cavitt, Jonathan
2025-02-06 16:58 ` Lucas De Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Cavitt, Jonathan @ 2025-02-06 16:33 UTC (permalink / raw)
To: Dheeraj Reddy Jonnalagadda, De Marchi, Lucas, thomas.hellstrom,
Vivi, Rodrigo
Cc: airlied, simona, intel-xe, dri-devel, linux-kernel, Cavitt, Jonathan
-----Original Message-----
From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Dheeraj Reddy Jonnalagadda
Sent: Thursday, February 6, 2025 5:47 AM
To: De Marchi, Lucas <lucas.demarchi@intel.com>; thomas.hellstrom@linux.intel.com; Vivi, Rodrigo <rodrigo.vivi@intel.com>
Cc: airlied@gmail.com; simona@ffwll.ch; intel-xe@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
Subject: [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo
>
> xe_vm_bind_kernel_bo() declares the variable fence without initializing
> it. If an error occurs before fence is assigned a valid value, the
> function may return an uninitialized pointer.
>
> Specifically, this can happen if:
>
> - vm_bind_ioctl_ops_create() fails, leading to release_vm_lock error
> path
>
> Initialize fence to NULL at declaration.
>
> Fixes: dcdd6b84d9ac ("drm/xe/pxp: Allocate PXP execution resources")
> Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
Fair enough.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
-Jonathan Cavitt
> ---
> drivers/gpu/drm/xe/xe_vm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index d664f2e418b2..b6ca53ede904 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3184,7 +3184,7 @@ struct dma_fence *xe_vm_bind_kernel_bo(struct xe_vm *vm, struct xe_bo *bo,
> {
> struct xe_vma_ops vops;
> struct drm_gpuva_ops *ops = NULL;
> - struct dma_fence *fence;
> + struct dma_fence *fence = NULL;
> int err;
>
> xe_bo_get(bo);
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo
2025-02-06 13:47 [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo Dheeraj Reddy Jonnalagadda
2025-02-06 16:33 ` Cavitt, Jonathan
@ 2025-02-06 16:58 ` Lucas De Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2025-02-06 16:58 UTC (permalink / raw)
To: Dheeraj Reddy Jonnalagadda
Cc: thomas.hellstrom, rodrigo.vivi, airlied, simona, intel-xe,
dri-devel, linux-kernel
On Thu, Feb 06, 2025 at 07:17:06PM +0530, Dheeraj Reddy Jonnalagadda wrote:
>xe_vm_bind_kernel_bo() declares the variable fence without initializing
>it. If an error occurs before fence is assigned a valid value, the
>function may return an uninitialized pointer.
>
>Specifically, this can happen if:
>
>- vm_bind_ioctl_ops_create() fails, leading to release_vm_lock error
> path
are you actually seeing an error or does this come from (static) analysis?
we are only on the error handling path when err is set to something.
Using your example:
ops = vm_bind_ioctl_ops_create(vm, bo, 0, addr, bo->size,
DRM_XE_VM_BIND_OP_MAP, 0, 0,
vm->xe->pat.idx[cache_lvl]);
if (IS_ERR(ops)) {
err = PTR_ERR(ops);
goto release_vm_lock;
}
all the other `goto ...` before `fence = ...` assign err, too.
On the the error handling we do:
if (err)
fence = ERR_PTR(err);
So I'm not seeing the bug mentioned.
Lucas De Marchi
>
>Initialize fence to NULL at declaration.
>
>Fixes: dcdd6b84d9ac ("drm/xe/pxp: Allocate PXP execution resources")
>Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
>---
> drivers/gpu/drm/xe/xe_vm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
>index d664f2e418b2..b6ca53ede904 100644
>--- a/drivers/gpu/drm/xe/xe_vm.c
>+++ b/drivers/gpu/drm/xe/xe_vm.c
>@@ -3184,7 +3184,7 @@ struct dma_fence *xe_vm_bind_kernel_bo(struct xe_vm *vm, struct xe_bo *bo,
> {
> struct xe_vma_ops vops;
> struct drm_gpuva_ops *ops = NULL;
>- struct dma_fence *fence;
>+ struct dma_fence *fence = NULL;
> int err;
>
> xe_bo_get(bo);
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-06 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-06 13:47 [PATCH] drm/xe: Fix uninitialized pointer read in xe_vm_bind_kernel_bo Dheeraj Reddy Jonnalagadda
2025-02-06 16:33 ` Cavitt, Jonathan
2025-02-06 16:58 ` Lucas De Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®