lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1646983382-30036-1-git-send-email-zheyuma97@gmail.com>
Date:   Fri, 11 Mar 2022 07:23:02 +0000
From:   Zheyu Ma <zheyuma97@...il.com>
To:     maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
        tzimmermann@...e.de, airlied@...ux.ie, daniel@...ll.ch
Cc:     dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
        Zheyu Ma <zheyuma97@...il.com>
Subject: [PATCH] drm: drm_bufs: Error out if 'dev->agp' is a null pointer

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@...il.com>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ