fix: grant Xwayland cap_ipc_owner for cross-user MIT-SHM - #107
Conversation
XWayland runs as the display-manager user (e.g. "dde") while desktop X11
clients (especially Electron/Chromium apps) may be launched by the real
login user. MIT-SHM (XShmPutImage) fails with BadAccess when the SysV
shared memory segment UID differs from the X server UID — the kernel's
ipcperms() denies shmat() for a 0600 segment owned by another user.
Grant cap_ipc_owner to the Xwayland binary so it can attach segments
created by any user on the machine. The X server still enforces its own
per-client access check (Xext/shm.c:shm_access, which verifies the client
owns the segment).
Three layers ensure the capability is always present:
- Install-time (debian/ddm.postinst): applies cap_ipc_owner=ep to the
Xwayland binary via setcap, so the first boot after installation
already has the fix.
- Runtime (DaemonApp.cpp::applyXwaylandIpcCapability): re-applies the
capability at every ddm startup, self-healing after Xwayland package
upgrades that may clear the file capability.
- Cleanup (debian/ddm.postrm): removes the capability on remove/purge
via setcap -r.
Depends on libcap2-bin (provides setcap).
Pair this with the treeland.service unit changes that disable
NoNewPrivileges and PrivateIPC (which would otherwise block the
capability or hide the segment via IPC namespace isolation).
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LFRon The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @LFRon. Thanks for your PR. 😃 |
|
Hi @LFRon. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideEnsure Xwayland always has cap_ipc_owner so MIT-SHM works across users by granting the capability at install time, re-applying it at daemon startup, and cleaning it up on removal, plus adding the necessary package dependency and a runtime helper in DaemonApp. Sequence diagram for Xwayland IPC capability lifecyclesequenceDiagram
participant Package as DebianPackage
participant DDM as DaemonApp
participant Setcap as setcap
participant Xwayland
participant Client as X11Client
participant Kernel
Package->>Setcap: setcap cap_ipc_owner=ep Xwayland
Setcap-->>Xwayland: File capability applied
DDM->>DDM: applyXwaylandIpcCapability()
DDM->>Setcap: QProcess::execute(cap_ipc_owner=ep, Xwayland)
Setcap-->>Xwayland: Capability re-applied
Client->>Xwayland: XShmPutImage
Xwayland->>Kernel: shmat(shared memory)
Kernel-->>Xwayland: Attach allowed by cap_ipc_owner
Xwayland-->>Client: Image displayed
Package->>Setcap: setcap -r Xwayland
Setcap-->>Xwayland: File capability removed
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
该PR修复了: Xwayland运行的QQ音乐白屏和微信最新版4.1.13.3只能显示第一帧, 之后完全卡住的问题
且该PR需要treeland侧的更改: linuxdeepin/treeland#1320
这个PR的实现撤掉了NoNewPrivileges和PrivateIPC, 具有一定风险, 仅作为一个参考实现
XWayland runs as the display-manager user (e.g. "dde") while desktop X11 clients (especially Electron/Chromium apps) may be launched by the real login user. MIT-SHM (XShmPutImage) fails with BadAccess when the SysV shared memory segment UID differs from the X server UID — the kernel's ipcperms() denies shmat() for a 0600 segment owned by another user.
Grant cap_ipc_owner to the Xwayland binary so it can attach segments created by any user on the machine. The X server still enforces its own per-client access check (Xext/shm.c:shm_access, which verifies the client owns the segment).
Three layers ensure the capability is always present:
Install-time (debian/ddm.postinst): applies cap_ipc_owner=ep to the Xwayland binary via setcap, so the first boot after installation already has the fix.
Runtime (DaemonApp.cpp::applyXwaylandIpcCapability): re-applies the capability at every ddm startup, self-healing after Xwayland package upgrades that may clear the file capability.
Cleanup (debian/ddm.postrm): removes the capability on remove/purge via setcap -r.
Depends on libcap2-bin (provides setcap).
Pair this with the treeland.service unit changes that disable NoNewPrivileges and PrivateIPC (which would otherwise block the capability or hide the segment via IPC namespace isolation).
Summary by Sourcery
Enable Xwayland to access cross-user SysV shared-memory segments and restore reliable rendering for desktop X11 clients.
Bug Fixes:
Enhancements:
Build: