G10: keep the DRM nodes at minor_perm across boots (logindevperm, drm-perms service) #12
Loading…
Reference in a new issue
No description provided.
Delete branch "g10-perms"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Anima work item: G10
01a102fe-2d96-7450-b51e-47446180ba24Stacked on #10 (
g7-coexist).Root cause
The packaged
virtio_gpuandcdrmnullnodes were0600 root rootafter a boot although/etc/minor_permsaid0666 root sys.minor_permwas right. The cause is the illumos-gate/etc/logindevpermrule/dev/vt/console_userpoints to/dev/consolewhile no VT is active. The ttymon ofconsole-login:default(-d /dev/console) opens the console at every boot and after every console logout, then callsdi_devperm_logout(). That function chowns every/dev/drinode to root's passwd owner and group (root root) andacl_strips it to 0600.devfs keeps the change in a shadow node on the on-disk
/devices.dv_shadow_nodeprefers the shadow tominor_perm, anddevfs_reset_perm(whatupdate_drv -mtriggers) skips shadowed nodes. Onlyrem_drv -Cremoves the shadow; IPS removes a driver withrem_drvwithout-C. So the wrong values survive reboots, reloads and reinstalls. This explains both the G7 findings and R0's note about drivers registered at boot.Evidence from the first boot after a fresh package install, traced with anonymous DTrace on
devfs_setattr/devfs_setsecattr(logs/hephaistos/illumos-drm/20261003-g10-run1-coldboot-repro.login the workspace):ttymonpid 353, at 18:31:51.56, 1.5 s afterdevice/local. It made 3 changes to each of the 4 nodes.ttymon_express → open_device → di_devperm_logout → logindevperm → dir_dev_acc → setdevaccess.crw------- root root(…-run1-shadow.log).Fix
drmadm permsis run by the new transient servicesvc:/system/graphics/drm-perms(packaging/drm-perms.xml, indriver/graphics/drmadm). The service runs at every boot afterdevice/localand before everyconsole-logininstance (anoptional_alldependent, so a failure cannot block the console). It also runs when the package is installed (restart_fmriofmanifest-import). It does two things:/dev/driwithout a driver list gets the legacy drivers' list (driver=i915,radeon), the documentedlogindevperm(5)mechanism.minor_perm.rename(2), keeping its owner and mode, and the rewrite is idempotent.minor_permentry are reset to it. The entry is chosen the way the kernel'sadd_minorperm/dev_minorpermchoose it. Only links whose driver is already loaded are followed: a lookup would attach the driver, and a loaded DRM module makesdrmadm selectrefuse.drmadm statusshows the rules and the nodes. The R0 security model is unchanged: render nodes are open to all, and card nodes are 0666 with master semantics in the core. README has a new Packaging section with the rule, the reasons, the rejected alternatives (per-minor perms, a post-console-login chmod,PRIVONLY_DEVminors) and the consequences:/etc/logindevpermis apreserve=truefile of SUNWcs. A later SUNWcs copy of it will not be installed while the edit is present;pkg revertit anddrmadm permsrestricts it again.Tests
tools/test/run-g10-test.shphases:arm: anonymous DTrace for the next boot;REVERT=1restores the packaged rule first.coldboot:0666 root sys, andnobodyopens every card and render node read-write.drmadm statuslists each node.rewrite,minorperm,repair,noload,driver-filter,upgrade.run-g7-test.sh installnow packagesdrm-perms.xml.Results on fresh guests of
golden-20260930on hephaistos (2 vCPUs, 3 GiB, virtio-gpu-gl). Logs arelogs/hephaistos/illumos-drm/20261003-g10-*in the workspace; the first line of each gives the revision.Before the fix (run1, G7 packages):
coldbootfails 19 checks — the 4 nodes0600 root rootwith their summary after the boot and again after a console-login restart (10), 4 opens bynobody, ttymon changing a node at the restart, the rule applying to every driver, and the 3 checks of the then-missing service.Full sequence (run3; drmadm at
1284ac0; the only later drmadm change is the round-2path_to_instfix, which run4 re-ran). Every phase passes:noloadminorpermrewritedriver-filterrepair(fault reproduced, then repaired)upgradeselect newselect legacyselect-newafter-newselect-legacyafter-legacyi915nselect-rootrollbackrun-r5a-test.sh(R0–R5a, packaged drivers removed,LEGACY_GUARD=skip)Final revision (run4, fresh guest at
5600545; later commits are README-only): first boot after the installationcoldboot25, traced boot with the packaged rule 29 (drm-perms' rename 2.1 s before ttymon's read; no ttymon change),noload2, G7select-new13,repair17, all PASS (…-g10-run4-*).Also: the first boot of a fresh install into a new boot environment (run2 at
5eb9710) passedcoldboot(25). The drm-perms log shows the rule restricted in that boot before console-login.Regression found and fixed on the way: run2's G7
select-newshowed that the firstdrmadm statusattached the drivers by following the links (fixed in0db4a73). run3's first coldboot found that pseudo devices are not inpath_to_inst(fixed in1284ac0).Review
Two Opus review rounds against the Anima bar. Round 1 rejected, and every point was fixed:
minor_permentry order (now the kernel's);preserve=truetrade-off in the docs;Round 2 approved. Its two non-blocking items are fixed in
5ab77fe:path_to_inst(the loaded one is taken; more than one loaded is reported);coldbootnow fails when the boot thatarmarmed has no trace.Open issues / notes
The driver of a
/dev/drilink comes from/etc/path_to_inst. Oncei915nships, an Intel GPU path will listi915andi915n.drmadmtakes the loaded one, but this has only been reasoned through, not tested with a real second driver (G5).libdevinfo's
check_driver_match()reads the driver name afterdi_fini(), a use-after-free in illumos-gate. The legacy rule's driver list now depends on it. It works today (driver-filter); this is noted in the README and not filed.The rule itself is illumos-gate's. Restricting it upstream would make the edit unnecessary; that is the owner's call.