Issue #3484 has been updated by tuxillo.

Related, but not covered by v2: on drivers that use TTM (radeon, amdgpu) an 
unknown offset doesn't panic, since drm_mmap_single() goes to 
ttm_bo_mmap_single() instead. But ttm_bo_mmap() returns -EINVAL when the lookup 
fails (ttm_bo_vm.c:440), and -EPERM or verify_access()'s negative value for the 
other failures. ttm_bo_mmap_single() returns that as is, and dev_dmmap_single() 
and vm_mmap() pass it on, so mmap(2) ends up returning a negative errno to 
userland. Might fit in with the other errno fixes you're doing.

----------------------------------------
Bug #3484: drm: mmap(2) of /dev/dri/card0 at an offset that is not a GEM offset 
panics the kernel
http://bugs.dragonflybsd.org/issues/3484#change-14989

* Author: sigttou
* Status: New
* Priority: Normal
* Category: Driver
* Target version: 6.6
* Start date: 2026-11-26
----------------------------------------
@mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0x1000000)@ on @/dev/dri/card0@ 
(also offset 0 or any page that is not a GEM mmap offset) panics the kernel:

  Fatal trap 12: page fault while in kernel mode
fault virtual address = 0x78   fault code = supervisor read data, page not 
present
panic: page fault
trap_fatal() <- trap_pfault() <- trap() <- calltrap() <- drm_mmap()+0x24 <- 
dev_dmmap()+0x55

@drm_gem_mmap_single()@ returns @ENODEV@ when no GEM object has the offset.  
@vm_mmap()@ takes @ENODEV@ from @dev_dmmap_single()@ as "use the device pager", 
the pager calls @drm_mmap()@ without a file, and @drm_mmap()@ reads 
@filp->private_data@ (0x78 is its offset in struct file) with @filp == NULL@.  
Any user who can open the device node (group video) can crash the machine with 
one call.

The attached patch makes @drm_mmap_single()@ fail the lookup with @EINVAL@, as 
Linux does, and makes @drm_mmap()@ refuse a call without a file.


---Files--------------------------------
0001-drm-fix-a-panic-on-mmap-at-an-unknown-offset.patch (1.82 KB)


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://bugs.dragonflybsd.org/my/account

Reply via email to