Skip to content

Conversation

@jsegitz
Copy link
Contributor

@jsegitz jsegitz commented Jul 18, 2025

When the key material is on a USB stick this currently doesn't work since cryptsetup will create a directory with a generic type

Solves avc: denied { associate } for pid=16385 comm="systemd-cryptse" name="cryptsetup" scontext=system_u:object_r:systemd_cryptsetup_generator_var_run_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=0

allow systemd_cryptsetup_generator_t systemd_cryptsetup_generator_var_run_t:file manage_file_perms;
allow systemd_cryptsetup_generator_t systemd_cryptsetup_generator_var_run_t:lnk_file manage_lnk_file_perms;

fs_associate_ramfs(systemd_cryptsetup_generator_var_run_t)
Copy link
Contributor

Choose a reason for hiding this comment

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

ramfs has been deprecated in favor of tmpfs in policy since commit 8e908b8

Anyway I am even more confused: tmpfs_t, but the type is ..._var_run_t, and filetrans interface is init_var_lib_filetrans()? Where is the dir actually created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The directory gets created in /run/systemd/, so the type should be fine

The fs_associate_ramfs call isn't necessary on my system, but the reporter has a special setup. I'll remove it, so we can get the basic change in there and then sent another PR just for the tmpfs change

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe init_pid_filetrans() is the right match given

2736 ## <summary>
2737 ##  Create objects in /run/systemd directory
2738 ##  with an automatic type transition to
2739 ##  a specified private type.
2740 ## </summary>

$ ls -lZd /run/systemd
drwxr-xr-x. 26 root root system_u:object_r:init_var_run_t:s0 720 27. srp 09.34 /run/systemd

The cryptsetup dir content is not used outside this generator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I didn't see the comment. I'll give init_pid_filetrans a try, but I can only do this after next week because my test vm needs an USB dongle attached, which I currently can't plug into the machine. Once I have access to the machine again I'll give it a go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes init_pid_filetrans is the better match, changed to that.

I don't know of any users of the cryptsetup dir as of now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me tag @zpytela to that he sees the change :)

@jsegitz jsegitz force-pushed the systemd_cryptsetup_generator_var_run_t branch from 6f4413b to aae1322 Compare July 25, 2025 07:18
When the key material is on a USB stick this currently doesn't work
since cryptsetup will create a directory with a generic type

Solves avc:  denied  { associate } for  pid=16385 comm="systemd-cryptse" name="cryptsetup" scontext=system_u:object_r:systemd_cryptsetup_generator_var_run_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=0
@jsegitz jsegitz force-pushed the systemd_cryptsetup_generator_var_run_t branch from aae1322 to 56a8bf8 Compare November 14, 2025 10:34
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.

2 participants