Issue #3484 has been updated by liweitianux.

It seems better to fix @drm_gem_mmap_single()@ to not return @ENODEV@ in the 
first place. That function is inside @#ifdef __DragonFly__@ so I think it 
belongs to our compat layer and is thus the correct place to fix.

----------------------------------------
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-14986

* 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 (2.38 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