mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm: drm_bufs: Error out if 'dev->agp' is a null pointer
Date: Thu, 17 Mar 2022 11:49:20 +0100	[thread overview]
Message-ID: <YjMSMIrbsVZjEw8W@phenom.ffwll.local> (raw)
In-Reply-To: <1646983382-30036-1-git-send-email-zheyuma97@gmail.com>

On Fri, Mar 11, 2022 at 07:23:02AM +0000, Zheyu Ma wrote:
> The user program can control the 'drm_buf_desc::flags' via ioctl system
> call and enter the function drm_legacy_addbufs_agp(). If the driver
> doesn't initialize the agp resources, the driver will cause a null
> pointer dereference.
> 
> The following log reveals it:
>     general protection fault, probably for non-canonical address
>     0xdffffc000000000f: 0000 [#1] PREEMPT SMP KASAN PTI
>     KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f]
>     Call Trace:
>      <TASK>
>      drm_ioctl_kernel+0x342/0x450 drivers/gpu/drm/drm_ioctl.c:785
>      drm_ioctl+0x592/0x940 drivers/gpu/drm/drm_ioctl.c:885
>      vfs_ioctl fs/ioctl.c:51 [inline]
>      __do_sys_ioctl fs/ioctl.c:874 [inline]
>      __se_sys_ioctl+0xaa/0xf0 fs/ioctl.c:860
>      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>      do_syscall_64+0x43/0x90 arch/x86/entry/common.c:80
>      entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> Fix this bug by adding a check.
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>

You can only hit this if you enabled a DRIVER_LEGACY drm driver, which
opens you up to tons of other CVEs and issues. What's your .config?
-Daniel

> ---
>  drivers/gpu/drm/drm_bufs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..4fe2363b1e34 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -734,7 +734,7 @@ int drm_legacy_addbufs_agp(struct drm_device *dev,
>  	int i, valid;
>  	struct drm_buf **temp_buflist;
>  
> -	if (!dma)
> +	if (!dma || !dev->agp)
>  		return -EINVAL;
>  
>  	count = request->count;
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2022-03-17 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  7:23 Zheyu Ma
2022-03-17 10:49 ` Daniel Vetter [this message]
2022-03-21 13:02   ` Zheyu Ma
2022-03-22 14:27     ` Daniel Vetter
2022-03-23  1:39       ` Zheyu Ma

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=YjMSMIrbsVZjEw8W@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=zheyuma97@gmail.com \
    /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

all inboxes | Powered by JetHome®