Skip to content

Conversation

WavyEbuilder
Copy link
Contributor

@WavyEbuilder WavyEbuilder commented Jul 10, 2025

A new type attribute wayland_compositor is introduced for shared rules for Wayland compositors. To support the security-context protocol[1], two new type attributes are introduced: wayland_client for regular Wayland clients, and wayland_client_sandboxed for sandboxed Wayland clients for use in applications run by sandbox engines such as Flatpak that support security-context[2].

As a fair amount of new policy modules can be expected to work with modern Wayland desktop sessions, a new policy layer has been created, session, to contain these new policy modules.

[1] https://wayland.app/protocols/security-context-v1
[2] flatpak/flatpak#4920

# No need to distinguish between the shm of sandboxed and unsandboxed clients;
# all clients should have their own shm type, this attribute is only to group them
# and grant wayland_compositor access to them.
attribute wayland_client_tmpfs_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be appropriate to go ahead and add files_tmpfs_file() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, seems reasonable, will do

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this resolved? I don't see a change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to reply, this interface doesn't appear to work on attributes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately, it's a language limitation. You'd have to put it in the interface.

Comment on lines +74 to +76
xserver_use_user_fonts(wayland_compositor)

xserver_read_xkb_libs(wayland_compositor)
xserver_rw_mesa_shader_cache(wayland_compositor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These xserver_() calls should go into an optional.

On the other hand I know it's perfectly possible to run a Wayland desktop without Xorg at all, so maybe this highlights a need to split some of these file types out of xserver in the future.

Copy link
Contributor Author

@WavyEbuilder WavyEbuilder Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's worth doing now (or possibly noting a dependency on the xserver module for now)? A compositor that doesn't have access to the mesa shader cache is pretty much useless...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should generalize the X fonts to simply user fonts, in userdomain or xdg? (suggestions please).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xdg sounds good to me, would you like a future PR for that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@aerusso
Copy link
Contributor

aerusso commented Jul 11, 2025

I've been building up a patchset that gets kde on wayland working with a slightly different set of primitives than this introduces. I haven't opened a PR for it partly because I hadn't yet figured out the best way to capture some of the primitives (which are captured here).

If this patch set is expected to be stable, I'll start re-basing my changes on this, and open a PR soon. Let me know! And, thanks for getting this started!

@WavyEbuilder
Copy link
Contributor Author

Hey,

I've been building up a patchset that gets kde on wayland working with a slightly different set of primitives than this introduces. I haven't opened a PR for it partly because I hadn't yet figured out the best way to capture some of the primitives (which are captured here).

Nice!

If this patch set is expected to be stable, I'll start re-basing my changes on this, and open a PR soon.

One thing I'm solving (and the final concern I have at the moment) is the shared memory (tmpfs_t) of the compositors, so I'm going to make an attribute for that tonight or latest tomorrow. After that all the interfaces should remain stable, ofc I suspect we'll in the future be able to remove some modules from kwin and future compositor modules and consolidate them into the typeattribute more as we get more practical experience of the accesses shared by compositors, but the interfaces themselves should remain stable.

And, thanks for getting this started!

No worries! Glad it could be of use. :)

@pebenito
Copy link
Member

One thing I'm solving (and the final concern I have at the moment) is the shared memory (tmpfs_t) of the compositors, so I'm going to make an attribute for that tonight or latest tomorrow.

@WavyEbuilder were you going to do further changes? I haven't started reviewing because of this.

@WavyEbuilder
Copy link
Contributor Author

One thing I'm solving (and the final concern I have at the moment) is the shared memory (tmpfs_t) of the compositors, so I'm going to make an attribute for that tonight or latest tomorrow.

@WavyEbuilder were you going to do further changes? I haven't started reviewing because of this.

Sorry! I made a change but forgot to commit and push. Will do now.

Comment on lines +13 to +31
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to fit wayland_compositor_tmpfs_type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I need to look more at wayland internals... is there a process to handle tmpfs stuff? The attribute naming seems like it should be a file type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so basically it's /dev/shm - Wayland clients have shared memory with the compositor that is written and read to. Take a look at https://wayland.app/protocols/wayland#wl_shm for associated interfaces. The compositor and the app have the tmpfs so basically imagine I have an app foo and a compositor bar, I'd have foo_t and foo_tmpfs_t, as well as bar_t and bar_tmpfs_t. They need to be able to rw each other's shared memory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, the doc is wrong (parameter name and summary), as the parameter is to be used as a file type, not a domain.

Comment on lines +39 to +69
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to fit wayland_client_tmpfs_type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be answered above.

@WavyEbuilder WavyEbuilder force-pushed the wayland-base branch 2 times, most recently from 12ec763 to ea8e486 Compare July 22, 2025 20:22
@WavyEbuilder WavyEbuilder requested a review from pebenito July 23, 2025 02:13
A new type attribute wayland_compositor is introduced for shared rules
for Wayland compositors. To support the security-context protocol[1],
two new type attributes are introduced: wayland_client for regular
Wayland clients, and wayland_client_sandboxed for sandboxed Wayland
clients for use in applications run by sandbox engines such as Flatpak
that support security-context[2].

As a fair amount of new policy modules can be expected to work with
modern Wayland desktop sessions, a new policy layer has been created,
session, to contain these new policy modules.

[1] https://wayland.app/protocols/security-context-v1
[2] flatpak/flatpak#4920

Signed-off-by: Rahul Sandhu <[email protected]>
@aerusso
Copy link
Contributor

aerusso commented Jul 28, 2025

I was hoping to get a more well-reasoned review for this prepared this weekend, but it will have to wait another week.

The long and short of it is that, while I've (again) got KDE running, this time using the primitives set out here, the situation is very messy. Handling things like the clipboard and the sundry other permissions wayland appears to, in practice has me with a block like this:

allow wayland_client wayland_compositor_tmpfs_type:file mmap_rw_inherited_file_perms;
allow wayland_client wayland_compositor:unix_stream_socket connectto;
allow wayland_client wayland_compositor:fd use;
allow wayland_client wayland_runtime_t:sock_file rw_sock_file_perms;
allow wayland_client wayland_client:fifo_file write;

allow wayland_compositor wayland_client_tmpfs_type:file mmap_rw_inherited_file_perms;
allow wayland_compositor wayland_client:fd use;
allow wayland_compositor wayland_client:fifo_file write;
allow wayland_compositor wayland_client_sandboxed:fd use;

The KDE module I have working is even worse. There seem to be no mechanisms to label memfd buffers beyond specific names, which for wayland are often very opaque, and many of which in are just very long random hexadecimal strings. I'm out of time for this for now, but I'll try to keep up with the conversation throughout the week.

@WavyEbuilder
Copy link
Contributor Author

WavyEbuilder commented Jul 28, 2025

allow wayland_client wayland_compositor_tmpfs_type:file mmap_rw_inherited_file_perms;
allow wayland_client wayland_compositor:unix_stream_socket connectto;
allow wayland_client wayland_compositor:fd use;
allow wayland_client wayland_runtime_t:sock_file rw_sock_file_perms;
allow wayland_client wayland_client:fifo_file write;

allow wayland_compositor wayland_client_tmpfs_type:file mmap_rw_inherited_file_perms;
allow wayland_compositor wayland_client:fd use;
allow wayland_compositor wayland_client:fifo_file write;
allow wayland_compositor wayland_client_sandboxed:fd use;

These don't seem particularly egregious - what's up with that? I don't personally seeing anything wrong with just granting those.

@WavyEbuilder
Copy link
Contributor Author

@aerusso @pebenito any updates?

@aerusso
Copy link
Contributor

aerusso commented Sep 20, 2025

@WavyEbuilder I've cherry picked your commit, and combined it with some other work of mine to get waypipe, kde, Xwayland, and basically all my other wayland applications working.

I was waiting for this patch to finalize, and then I was going to rebase (and clean up) those patches, and then submit them. The KDE patches are pretty significant, so those would come second. There are core improvements (e.g., Xwayland) and other somewhat simpler things (waypipe) that would be good examples to help work out an interface for the new module before diving into all of KDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants