Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues: - [Critical] Direct access to ctx->vm in ioctl entry point without preceding call to msm_context_vm() causes NULL pointer dereference. - [High] Unchecked ERR_PTR assignment from msm_context_vm() leads to kernel crash in submit_lock_objects(). -- --- Patch [7]: [PATCH v7 07/17] drm/msm/a6xx: Access VM directly in submit path --- commit fb968654323d1792a0d26ac37c9d0a8e1d71c1dd Author: Rob Clark <[email protected]> drm/msm/a6xx: Access VM directly in submit path The GEM_SUBMIT ioctl has already ensured that the VM is created, so we aren't expecting to lazily create the VM this deep into the ioctl. > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > index e293b4ca808a4..9240c4af687c9 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > @@ -229,7 +229,7 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, > { > bool sysprof = msm_gpu_sysprof_no_perfcntr_zap(&a6xx_gpu->base.base); > struct msm_context *ctx = submit->queue->ctx; > - struct drm_gpuvm *vm = msm_context_vm(submit->dev, ctx); > + struct drm_gpuvm *vm = ctx->vm; [Severity: Critical] This is a pre-existing issue, but since the commit message mentions that the GEM_SUBMIT ioctl has already ensured that the VM is created, I wanted to ask about msm_ioctl_gem_submit(). Looking at msm_ioctl_gem_submit() in drivers/gpu/drm/msm/msm_gem_submit.c, it accesses ctx->vm directly: drivers/gpu/drm/msm/msm_gem_submit.c:msm_ioctl_gem_submit() { ... if (args->pad) return -EINVAL; if (to_msm_vm(ctx->vm)->unusable) return UERR(EPIPE, dev, "context is unusable"); ... } Can this cause a NULL pointer dereference if an unprivileged user creates a legacy submit queue without VM_BIND and immediately calls the submit ioctl? The VM is initialized lazily, so it seems ctx->vm could be NULL here if we haven't called msm_context_vm() first. [Severity: High] This is another pre-existing issue, but I wanted to check how we handle VM allocation failures in the submit path. In submit_create() in drivers/gpu/drm/msm/msm_gem_submit.c: drivers/gpu/drm/msm/msm_gem_submit.c:submit_create() { ... submit->vm = msm_context_vm(dev, queue->ctx); ... } msm_context_vm() can return an ERR_PTR(-ENOMEM). Later in the same ioctl, submit_lock_objects() unconditionally dereferences it: drivers/gpu/drm/msm/msm_gem_submit.c:submit_lock_objects() { ... drm_exec_until_all_locked (&submit->exec) { ret = drm_exec_lock_obj(&submit->exec, drm_gpuvm_resv_obj(submit->vm)); ... } Does submit->vm need an IS_ERR() check after calling msm_context_vm() to prevent a kernel crash if the VM allocation fails? > struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; > phys_addr_t ttbr; > u32 asid; -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=7
