Repository navigation
fix(matching): don't read the SELinux label as a snap id - #154
Merged
Merged
Conversation
get_snap_app_id_from_pid used the snapd C macro *name* "SNAP_SECURITY_LABEL_PREFIX" as a string literal; the macro's value is "snap.". The literal matched nothing, and the function unconditionally returned is_snap = true whenever /proc/<pid>/attr/current could be read. On SELinux distributions every process has that file, so determine_desktop_file_app_id_from_pid() returned the SELinux context and MetaWindow::patch_meta_window overwrote the real app id with it (Konsole's org.kde.konsole became unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023). The matcher then found no app-id candidate and dropped every launch into a new "unknown" tile. Parse the AppArmor label with the real prefix and require it, so SELinux contexts, unconfined profiles and any other non-snap label return no snap. This also stops the context from leaking into ProcessInfo::snap_id. Seen in a "Launch and record" dump on Fedora Kinoite 44: a tracked Konsole launch reported appId as the SELinux context and "_matching fallback: outcome newWindow, trackedWindowId null".
Contributor
Author
|
Verified end-to-end on the Fedora Kinoite 44 VM with a debug build of this branch: a tracked Konsole launch now matches its Note: the VM has no GPU, and the Flutter debug engine then segfaults in Mesa |
This was referenced Oct 16, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Fedora (SELinux), window matching is broken for ordinary applications: a tracked launch of an app lands in a fresh, empty "unknown" tile instead of its placeholder. Captured with a debug build on Fedora Kinoite 44 via ⋮ → "Launch and record", the dump shows the window's app id is the SELinux context:
{"method":"meta_window_created","message":{"appId":"unconfined_u:unconfined_r:unconfined_t:s0-s0:c0_c1023\u0000", ...}} {"method":"meta_window_patch","message":{"value":"unconfined_u:unconfined_r:unconfined_t:s0-s0:c0_c1023\u0000","type":"UpdateAppId"}} {"method":"_matching","message":{"kind":"fallback","outcome":"newWindow","trackedWindowId":null,...}} {"method":"_matching","message":{"kind":"display","windowId":"p:c115d3ef-…","displayedWindowId":"cef79471-…"}}The target placeholder was
org.kde.konsole; with no candidate for the garbage app id the matcher fell through to "create a new window".Root cause
get_snap_app_id_from_pid(src/embedder/meta_window_state/mod.rs) was written for Ubuntu/AppArmor but ported with the snapd C macro name instead of its value:SNAP_SECURITY_LABEL_PREFIXis a snapd macro whose value is"snap.". Because the literal never matched, the function reportedis_snap = truefor every process whose/proc/<pid>/attr/currentis readable — which, under SELinux, is every process.determine_desktop_file_app_id_from_pid()then returned the SELinux context, andMetaWindow::patch_meta_window(meta_window.rs:318) overwrote the real app id with it (.or()prefers the pid-derived id). The same context also leaked intoProcessInfo::snap_id.Fix
SNAP_SECURITY_LABEL_PREFIX = "snap."(the real value).snap_app_id_from_security_label()requires the prefix to be present and otherwise returnsNone, so SELinux contexts,docker-default,unconfined, etc. are not snaps.get_snap_app_id_from_piduses it.Tests
Two unit tests cover the parsing:
snap.firefox.firefox (enforce)→firefox_firefox, and SELinux/AppArmor non-snap labels →None.cargo testpasses (meta_window_state::tests::{snap_security_labels_resolve_to_the_desktop_app_id, non_snap_security_labels_are_never_treated_as_snaps}).Verification note
End-to-end re-run on the Kinoite VM is in progress. The VM has no GPU (Mesa
llvmpipe), where the Flutter debug engine segfaults intermittently in the software rasterizer, which also leaves the DRM device wedged for the next start — a pre-existing environment issue unrelated to this change. I'll confirm the tile now matches once a clean run completes; the unit-level behavior (the parsing that caused the wrong app id) is covered above.