Issue #3499 has been reported by sigttou.
----------------------------------------
Bug #3499: drm: after a VT switch X is no longer the DRM master: DRI2
authentication fails, the console takes the display on hotplug
http://bugs.dragonflybsd.org/issues/3499
* Author: sigttou
* Status: New
* Priority: Normal
* Target version: 6.6
* Start date: 2026-12-04
----------------------------------------
@drm_is_current_master()@ (@sys/dev/drm/drm_auth.c@) only returns
@fpriv->is_master@, which is never cleared. Linux 4.14 also requires that the
file's master object is the one installed on the device. The effect with Xorg:
- X is the first opener of the node and becomes master (@dev->master@ = X's
master object).
- On VT leave X issues @DRM_IOCTL_DROP_MASTER@: it succeeds and @dev->master@
becomes NULL.
- On VT enter X issues @DRM_IOCTL_SET_MASTER@: @drm_setmaster_ioctl()@ finds
@drm_is_current_master(file_priv)@ true and returns 0 without restoring
@dev->master@.
While @dev->master@ is NULL, X's later @DROP_MASTER@ fails with EINVAL
(@Xorg.0.log@: the first VT leave is clean, every later one logs @(WW)
intel(0): drmDropMaster failed: Invalid argument@). A client that opens the
node becomes master itself through @drm_master_open()@ and registers its magic
in its own master object, so X's @AUTH_MAGIC@ fails (Mesa: @DRI2: failed to
authenticate@, @libGL error: failed to authenticate magic 1@, no GPU context in
mpv). @drm_fb_helper_is_bound()@ no longer keeps the fbdev helper off the
display, so the kernel console takes it on a connector hotplug. Restarting X
cures it.
The 2021 commit 4ec80808ee ('Hack around a drm_setmaster issue') disabled the
@dev->master@ check in @drm_setmaster_ioctl()@. That is kept. The first patch
makes @drm_is_current_master()@ also compare @fpriv->master@ with
@dev->master@, so X's @SET_MASTER@ after @DROP_MASTER@ restores @dev->master@,
and a former master can no longer drop the mastership of a later @SET_MASTER@
caller.
The second patch fixes a leak that the first one makes easier to hit:
@drm_set_master()@ installs a new @dev->master@ without dropping the reference
held by the one it replaces. A file that became master first, or a client that
opened the node while X was VT-switched away, is replaced by X's @SET_MASTER@,
and its @drm_master@ object and magic map are never freed. The patch drops the
device's reference first. The file that owns the displaced master keeps its own.
Reporter: @vjkarbo
---Files--------------------------------
0001-drm-fix-DRM-master-bookkeeping-after-a-VT-switch.patch (1.61 KB)
0002-drm-drop-the-displaced-master-reference-in-drm_set_m.patch (1.54 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