mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alessio Belle <Alessio.Belle@imgtec.com>
To: Luigi Santivetti <Luigi.Santivetti@imgtec.com>
Cc: Brajesh Gupta <Brajesh.Gupta@imgtec.com>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	Frank Binns <Frank.Binns@imgtec.com>,
	"boris.brezillon@collabora.com" <boris.brezillon@collabora.com>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Alexandru Dadu <Alexandru.Dadu@imgtec.com>
Subject: Re: [PATCH] drm/imagination: fix error checking of pvr_vm_context_lookup()
Date: Wed, 8 Jul 2026 13:22:42 +0000	[thread overview]
Message-ID: <fbcad7c8285c255cb09b31e39303fd88e7de3bb2.camel@imgtec.com> (raw)
In-Reply-To: <20260707-staging-ddkopsrc-2435-v1-1-24e160d44476@imgtec.com>

On Tue, 2026-07-07 at 16:17 +0100, Luigi Santivetti wrote:
> Since pvr_vm_context_lookup() returns either NULL or a pointer, then stop
> using IS_ERR() for checking the return value.
> 
> Using IS_ERR() leads to the kernel oops reported below. It can be
> reproduced by passing an invalid VM context handle from userspace to the
> DRM_IOCTL_PVR_CREATE_CONTEXT ioctl.
> 
> [   92.733119] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000148
> [   92.742042] Mem abort info:
> [   92.744890]   ESR = 0x0000000096000004
> [   92.748686]   EC = 0x25: DABT (current EL), IL = 32 bits
> [   92.754020]   SET = 0, FnV = 0
> [   92.757154]   EA = 0, S1PTW = 0
> [   92.760337]   FSC = 0x04: level 0 translation fault
> [   92.765243] Data abort info:
> [   92.768129]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
> [   92.773626]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
> [   92.778763]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
> [   92.784098] user pgtable: 4k pages, 48-bit VAs, pgdp=000000088ed23000
> [   92.790550] [0000000000000148] pgd=0000000000000000, p4d=0000000000000000
> [   92.797381] Internal error: Oops: 0000000096000004 [#1]  SMP
> [   92.803027] Modules linked in: powervr
> [   92.852533] CPU: 0 UID: 0 PID: 409 Comm: triangle Not tainted 7.1.0-rc5-g98b46e693b91 #1 PREEMPT
> [   92.861385] Hardware name: Texas Instruments AM68 SK (DT)
> [   92.866766] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [   92.873709] pc : pvr_vm_get_fw_mem_context+0x0/0xc [powervr]
> [   92.879376] lr : pvr_queue_create+0x26c/0x440 [powervr]
> [   92.884595] sp : ffff8000837fbb00
> [   92.887895] x29: ffff8000837fbb60 x28: 0000000000000000 x27: ffff8000837fbce8
> [   92.895015] x26: ffff000807f61a40 x25: ffff000807f61a00 x24: ffff000807f64400
> [   92.902135] x23: ffff00080a5ab000 x22: ffff800079b24730 x21: ffff000807f61800
> [   92.909254] x20: ffff00080999e680 x19: 0000000000000000 x18: 0000000000000000
> [   92.916373] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000001
> [   92.923492] x14: 0000000000000000 x13: 0000000000000002 x12: ffff80008145b298
> [   92.930611] x11: ffff8000844e5000 x10: ffff80008165a130 x9 : 0000000000000100
> [   92.937730] x8 : 0000000000000001 x7 : ffff0008076b27e0 x6 : ffff00080ec43b7c
> [   92.944850] x5 : ffff00080ec43b78 x4 : 0000000000000000 x3 : ffff00080999e680
> [   92.951968] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
> [   92.959088] Call trace:
> [   92.961521]  pvr_vm_get_fw_mem_context+0x0/0xc [powervr] (P)
> [   92.967173]  pvr_context_create+0x190/0x410 [powervr]
> [   92.972218]  pvr_ioctl_create_context+0x44/0x8c [powervr]
> [   92.977608]  drm_ioctl_kernel+0xbc/0x124 [drm]
> [   92.982127]  drm_ioctl+0x1f8/0x4dc [drm]
> [   92.986098]  __arm64_sys_ioctl+0xac/0x104
> [   92.990102]  invoke_syscall+0x54/0x10c
> [   92.993842]  el0_svc_common.constprop.0+0x40/0xe0
> [   92.998532]  do_el0_svc+0x1c/0x28
> [   93.001835]  el0_svc+0x38/0x11c
> [   93.004969]  el0t_64_sync_handler+0xa0/0xe4
> [   93.009139]  el0t_64_sync+0x198/0x19c
> [   93.012792] Code: aa1703e0 d2800014 95cb0ba4 17ffffe8 (f940a400)
> [   93.018869] ---[ end trace 0000000000000000 ]---
> 
> Fixes: d2d79d29bb98 ("drm/imagination: Implement context creation/destruction ioctls")
> Cc: stable@vger.kernel.org
> Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>

Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>

Thanks,
Alessio

> ---
>  drivers/gpu/drm/imagination/pvr_context.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_context.c b/drivers/gpu/drm/imagination/pvr_context.c
> index eba4694400b5..512f3735223e 100644
> --- a/drivers/gpu/drm/imagination/pvr_context.c
> +++ b/drivers/gpu/drm/imagination/pvr_context.c
> @@ -307,8 +307,8 @@ int pvr_context_create(struct pvr_file *pvr_file, struct drm_pvr_ioctl_create_co
>  		goto err_free_ctx;
>  
>  	ctx->vm_ctx = pvr_vm_context_lookup(pvr_file, args->vm_context_handle);
> -	if (IS_ERR(ctx->vm_ctx)) {
> -		err = PTR_ERR(ctx->vm_ctx);
> +	if (!ctx->vm_ctx) {
> +		err = -EINVAL;
>  		goto err_free_ctx;
>  	}
>  
> 
> ---
> base-commit: f7606400f19ca0291718ce4eed5770798890ea2f
> change-id: 20260707-staging-ddkopsrc-2435-90d4d218383b
> 
> Best regards,
> --  
> Luigi Santivetti <luigi.santivetti@imgtec.com>
> 


  reply	other threads:[~2026-07-08 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 15:17 Luigi Santivetti
2026-07-08 13:22 ` Alessio Belle [this message]
2026-07-09 14:13 ` Alessio Belle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbcad7c8285c255cb09b31e39303fd88e7de3bb2.camel@imgtec.com \
    --to=alessio.belle@imgtec.com \
    --cc=Alexandru.Dadu@imgtec.com \
    --cc=Brajesh.Gupta@imgtec.com \
    --cc=Frank.Binns@imgtec.com \
    --cc=Luigi.Santivetti@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox