drm: drm_bufs: Error out if 'dev->agp' is a null pointer
Subsystems (2)
PATCH 1/1 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/0xaeFix this bug by adding a check.
--- drivers/gpu/drm/drm_bufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_bufs.c +1 -1
@@ -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;
Signature · 1 line
2.25.1
Quoted 20 lines · Zheyu Ma
The user program can control the '
drm_buf_desc::flags' via ioctl system call and enter the functiondrm_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
Quoted 3 lines
Fix this bug by adding a check.
Signed-off-by Zheyu Ma <[email protected]>
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
Quoted 20 lines
--- drivers/gpu/drm/drm_bufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_bufs.c +1
-1@@ -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;Signature · 1 line
2.25.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 22 lines · Daniel Vetter
Quoted 20 lines · Zheyu Ma
The user program can control the '
drm_buf_desc::flags' via ioctl system call and enter the functiondrm_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
Quoted 6 lines
Quoted 3 lines
Fix this bug by adding a check.
Signed-off-by Zheyu Ma <[email protected]>You can only hit this if you enabled a
DRIVER_LEGACYdrm driver, which opens you up to tons of other CVEs and issues. What's your .config?
Yes, I enable the DRM_LEGACY option in the config.
I think you mean this is not a normal configuration file? Do you have a recommended configuration option for when I want to test the GPU driver?
Actually, I use the following configs related to GPU:
CONFIG_AGP=yCONFIG_AGP_AMD64=yCONFIG_AGP_INTEL=yCONFIG_AGP_SIS=yCONFIG_AGP_VIA=yCONFIG_INTEL_GTT=yCONFIG_VGA_ARB=yCONFIG_VGA_ARB_MAX_GPUS=16CONFIG_DRM=yCONFIG_DRM_MIPI_DSI=yCONFIG_DRM_KMS_HELPER=yCONFIG_DRM_DEBUG_MODESET_LOCK=yCONFIG_DRM_FBDEV_EMULATION=yCONFIG_DRM_FBDEV_OVERALLOC=100CONFIG_DRM_TTM=yCONFIG_DRM_VRAM_HELPER=yCONFIG_DRM_TTM_HELPER=yCONFIG_DRM_GEM_SHMEM_HELPER=yCONFIG_DRM_SCHED=yCONFIG_DRM_RADEON=yCONFIG_DRM_AMDGPU=yCONFIG_DRM_AMD_DC=yCONFIG_DRM_AMD_DC_DCN=yCONFIG_DRM_I915=yCONFIG_DRM_I915_FORCE_PROBE=""CONFIG_DRM_I915_CAPTURE_ERROR=yCONFIG_DRM_I915_COMPRESS_ERROR=yCONFIG_DRM_I915_USERPTR=yCONFIG_DRM_I915_REQUEST_TIMEOUT=20000CONFIG_DRM_I915_FENCE_TIMEOUT=10000CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND=250CONFIG_DRM_I915_HEARTBEAT_INTERVAL=2500CONFIG_DRM_I915_PREEMPT_TIMEOUT=640CONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT=8000CONFIG_DRM_I915_STOP_TIMEOUT=100CONFIG_DRM_I915_TIMESLICE_DURATION=1CONFIG_DRM_VMWGFX=yCONFIG_DRM_GMA500=yCONFIG_DRM_UDL=yCONFIG_DRM_AST=yCONFIG_DRM_MGAG200=yCONFIG_DRM_QXL=yCONFIG_DRM_VIRTIO_GPU=yCONFIG_DRM_PANEL=yCONFIG_DRM_BRIDGE=yCONFIG_DRM_PANEL_BRIDGE=yCONFIG_DRM_BOCHS=yCONFIG_DRM_CIRRUS_QEMU=yCONFIG_DRM_GM12U320=yCONFIG_DRM_VBOXVIDEO=yCONFIG_DRM_GUD=yCONFIG_DRM_HYPERV=yCONFIG_DRM_LEGACY=yCONFIG_DRM_TDFX=yCONFIG_DRM_R128=yCONFIG_DRM_MGA=yCONFIG_DRM_SIS=yCONFIG_DRM_VIA=yCONFIG_DRM_SAVAGE=yCONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y
Thanks,
Zheyu Ma
Quoted 27 lines · Zheyu Ma
Quoted 26 lines · Daniel Vetter
Quoted 23 lines · Zheyu Ma
The user program can control the '
drm_buf_desc::flags' via ioctl system call and enter the functiondrm_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/0xaeFix this bug by adding a check.
Signed-off-by Zheyu Ma <[email protected]>
Quoted 7 lines
Quoted 2 lines
You can only hit this if you enabled a
DRIVER_LEGACYdrm driver, which opens you up to tons of other CVEs and issues. What's your .config?Yes, I enable the
DRM_LEGACYoption in the config.
I think you mean this is not a normal configuration file? Do you have a recommended configuration option for when I want to test the GPU driver?
Yeah DRM_LEGACY gives you all kinds of horrible and known-broken interfaces. Don't enable that :-)
You have a bunch of other drivers enable which require DRM_LEGACY, so those will disable too. Anything else I think would be an upstream bug and we'd need to adjust Kconfig (or fix the code).
Cheers, Daniel
Quoted 66 lines
Actually, I use the following configs related to GPU:
CONFIG_AGP=yCONFIG_AGP_AMD64=yCONFIG_AGP_INTEL=yCONFIG_AGP_SIS=yCONFIG_AGP_VIA=yCONFIG_INTEL_GTT=yCONFIG_VGA_ARB=yCONFIG_VGA_ARB_MAX_GPUS=16CONFIG_DRM=yCONFIG_DRM_MIPI_DSI=yCONFIG_DRM_KMS_HELPER=yCONFIG_DRM_DEBUG_MODESET_LOCK=yCONFIG_DRM_FBDEV_EMULATION=yCONFIG_DRM_FBDEV_OVERALLOC=100CONFIG_DRM_TTM=yCONFIG_DRM_VRAM_HELPER=yCONFIG_DRM_TTM_HELPER=yCONFIG_DRM_GEM_SHMEM_HELPER=yCONFIG_DRM_SCHED=yCONFIG_DRM_RADEON=yCONFIG_DRM_AMDGPU=yCONFIG_DRM_AMD_DC=yCONFIG_DRM_AMD_DC_DCN=yCONFIG_DRM_I915=yCONFIG_DRM_I915_FORCE_PROBE=""CONFIG_DRM_I915_CAPTURE_ERROR=yCONFIG_DRM_I915_COMPRESS_ERROR=yCONFIG_DRM_I915_USERPTR=yCONFIG_DRM_I915_REQUEST_TIMEOUT=20000CONFIG_DRM_I915_FENCE_TIMEOUT=10000CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND=250CONFIG_DRM_I915_HEARTBEAT_INTERVAL=2500CONFIG_DRM_I915_PREEMPT_TIMEOUT=640CONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT=8000CONFIG_DRM_I915_STOP_TIMEOUT=100CONFIG_DRM_I915_TIMESLICE_DURATION=1CONFIG_DRM_VMWGFX=yCONFIG_DRM_GMA500=yCONFIG_DRM_UDL=yCONFIG_DRM_AST=yCONFIG_DRM_MGAG200=yCONFIG_DRM_QXL=yCONFIG_DRM_VIRTIO_GPU=yCONFIG_DRM_PANEL=yCONFIG_DRM_BRIDGE=yCONFIG_DRM_PANEL_BRIDGE=yCONFIG_DRM_BOCHS=yCONFIG_DRM_CIRRUS_QEMU=yCONFIG_DRM_GM12U320=yCONFIG_DRM_VBOXVIDEO=yCONFIG_DRM_GUD=yCONFIG_DRM_HYPERV=yCONFIG_DRM_LEGACY=yCONFIG_DRM_TDFX=yCONFIG_DRM_R128=yCONFIG_DRM_MGA=yCONFIG_DRM_SIS=yCONFIG_DRM_VIA=yCONFIG_DRM_SAVAGE=yCONFIG_DRM_PANEL_ORIENTATION_QUIRKS=yThanks,
Zheyu Ma
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 37 lines · Daniel Vetter
Quoted 27 lines · Zheyu Ma
Quoted 26 lines · Daniel Vetter
Quoted 23 lines · Zheyu Ma
The user program can control the '
drm_buf_desc::flags' via ioctl system call and enter the functiondrm_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/0xaeFix this bug by adding a check.
Signed-off-by Zheyu Ma <[email protected]>Quoted 7 lines
Quoted 2 lines
You can only hit this if you enabled a
DRIVER_LEGACYdrm driver, which opens you up to tons of other CVEs and issues. What's your .config?Yes, I enable the
DRM_LEGACYoption in the config.
I think you mean this is not a normal configuration file? Do you have a recommended configuration option for when I want to test the GPU driver?
Quoted 6 lines
Yeah
DRM_LEGACYgives you all kinds of horrible and known-broken interfaces. Don't enable that :-)You have a bunch of other drivers enable which require
DRM_LEGACY, so those will disable too. Anything else I think would be an upstream bug and we'd need to adjustKconfig(or fix the code).
Thanks for your explanation! I will pay attention next time.
Regards,
Zheyu Ma