Skip to content

Conversation

@Conan-Kudo
Copy link
Member

This ensures that the kiwi executable is labeled such that it works properly in SELinux enforcing mode.

@Conan-Kudo
Copy link
Member Author

This is an alternative to #2756 that does the bare minimum.

@Conan-Kudo Conan-Kudo marked this pull request as ready for review March 28, 2025 14:03
@Conan-Kudo Conan-Kudo requested a review from schaefi March 28, 2025 14:04
@Conan-Kudo Conan-Kudo force-pushed the kiwi-selinux-context branch from 9f6e80a to 93d6f0d Compare March 28, 2025 14:23
This ensures that the kiwi executable is labeled such that it works
properly in SELinux enforcing mode.
Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

I have asked the security team for a review, but they won't be able to do so until next week. Please hold unless you absolutely must merge this week

@Conan-Kudo
Copy link
Member Author

Note that if SUSE security rejects this, then I will simply just exclude it from SUSE distributions.

@Conan-Kudo
Copy link
Member Author

The other option would be to create an SELinux policy module similar to what the osbuild folks have. They define a domain for osbuild and then make it an unconfined domain.

@rfrohl
Copy link

rfrohl commented Mar 28, 2025

Note that if SUSE security rejects this, then I will simply just exclude it from SUSE distributions.

I think there was a bit of wrong understanding here: The SELinux team got a ping to look at this change , but we do not have time this week (as it is almost weekend here). The initial question I had was why this can not go into the general policy and is handled in %post/%postun instead ?

We simply would look at this next week to understand this better.

@rfrohl
Copy link

rfrohl commented Mar 31, 2025

Is there a reason why this should not go into https://github.com/fedora-selinux/selinux-policy ? We use rawhide as our upstream and could simply add it there, if they are willing to take it.

Especially since you want to use the solution for multiple distributions, which I assume to mean Fedora. If it is added to the policy then it would be there already as well.

@Conan-Kudo
Copy link
Member Author

Conan-Kudo commented Mar 31, 2025

Is there a reason why this should not go into https://github.com/fedora-selinux/selinux-policy ? We use rawhide as our upstream and could simply add it there, if they are willing to take it.

Especially since you want to use the solution for multiple distributions, which I assume to mean Fedora. If it is added to the policy then it would be there already as well.

I will probably send it there too, but there still will be lag for months (!!!) across CentOS, Fedora, and SUSE distributions before it will be available everywhere.

@rfrohl
Copy link

rfrohl commented Mar 31, 2025

there still will be lag for months (!!!)

So you would remove the %post/%postun change again, once the policy change landed in all the relevant places ?

The change had a smell to it, which is why I engaged. Using just semanage to manage the new file context will be error prone. Depending on how the users manage their systems, the file context might disappear. Leading to bugs that are hard to figure out, and these might land on our table so I wanted to make sure that the goal of this change is well understood.

@Conan-Kudo
Copy link
Member Author

Eventually it will be guarded out for distributions where the policy has been updated. Most likely it would be dropped for kiwi 11 next year.

@Conan-Kudo
Copy link
Member Author

(But yes, I'm working on a policy module that will probably be contributed to fedora-selinux.)

%post -n python%{python3_pkgversion}-kiwi
if [ -x /usr/sbin/semanage -a -x /usr/sbin/restorecon ]; then
# file contexts
semanage fcontext --add --type install_exec_t '%{_bindir}/kiwi' 2> /dev/null || :
Copy link

Choose a reason for hiding this comment

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

Why is adding the fcontext need?

The change from https://github.com/OSInside/kiwi/pull/2756/files, introduced these file context in the kiwi-selinux module:

/usr/bin/kiwi			--	gen_context(system_u:object_r:install_exec_t,s0)
/usr/bin/kiwi-ng(.*)		--	gen_context(system_u:object_r:install_exec_t,s0)

By my understand the fcontext should be available. Am I missing something?

Copy link

Choose a reason for hiding this comment

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

Ah i see, the change was declined.

Copy link

Choose a reason for hiding this comment

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

Is the plan not to have a module and use the post/postun instead of a module?

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, yes. A module needs some more work before we go to that.

Copy link

Choose a reason for hiding this comment

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

ok, thank you for being patient with my questions

@rfrohl
Copy link

rfrohl commented Mar 31, 2025

So I could offer to backport any submission to fedora-selinux/selinux-policy into our selinux-policy. That I think would lead to a cleaner solution, then adding these fcontext manually during package install.

Which is really the main issue that I have with this change: that these fcontext's are not part of any policy and would only show up once the %post ran. That there is not even a separate selinux module will make this almost impossible to find. Therefor needing quite a bit of detail knowledge to find the root cause, if issues are reported.
edit: Plus if the user interacts with the policy in strange ways, then these additions could also be removed from the running policy.

@Conan-Kudo
Copy link
Member Author

I could go back to #2756 approach, but I need to add a few more things to use that.

@rfrohl
Copy link

rfrohl commented Mar 31, 2025

I could go back to #2756 approach, but I need to add a few more things to use that.

I think that would be cleaner. The benefit from that solution from my POV: it uses a standard approach that will be on peoples radar, even though modules that are not part of the main policy can be a problem in some ways, they are still better then dynamic change to the running policy of a system.

@Conan-Kudo
Copy link
Member Author

Okay, I'll switch to that. Reopened that PR as draft and am closing this one.

@Conan-Kudo Conan-Kudo closed this Mar 31, 2025
@schaefi schaefi deleted the kiwi-selinux-context branch May 13, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants