Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selinux: allow oddjobd to set up ipa_helper_t context for execution #4882

Closed
wants to merge 2 commits into from

Conversation

abbra
Copy link
Contributor

@abbra abbra commented Jul 2, 2020

On Fedora 32+ and RHEL 8.3.0+ SELinux policy requires explicit process
transition from httpd_t context. In addition, a setup of a helper
execution needs permission to use 'noatsecure', 'rlimitinh', and
'siginh'. These operations invoked during execve() setup by glibc.

Fixes: https://pagure.io/freeipa/issue/8395
Signed-off-by: Alexander Bokovoy abokovoy@redhat.com

@abbra
Copy link
Contributor Author

abbra commented Jul 2, 2020

Please see http://blog.siphos.be/2011/04/selinux-and-noatsecure-or-why-portage-complains-about-ld_preload-and-libsandbox-so/ for explanation about noatsecure appearance.

This fix should make fetching of trust topology information working again. The denials are part of don't audit rules and thus were not visible otherwise, causing weird issue with Samba Python bindings not being able to discover proper current kerberos configuration.

As a result, the code went with assumption that the current principal (trusted domain object's credential from AD realm) in a credentials cache belongs to the default realm (IPA). This caused an attempt to request a cross-realm referral to AD domain controller and since the trust is one-way by default (and into an opposite direction), it was rejected by KDC.

selinux/ipa.te Outdated Show resolved Hide resolved
@abbra
Copy link
Contributor Author

abbra commented Jul 2, 2020

After discussing with @zpytela and others, we came to the following conclusion:

  • we need to extend oddjob policy interface to provide a way to tell ipa_helper_t is allowed to use noatsecure when when transitioning from oddjob_t
  • we need to add a call to this interface to ipa policy.

Additionally I found that there is an attempt to load selinux policy from ipa-getkeytab, most likely due to libkrb5 initialization. This is denied for ipa_helper_exec_t context and needs to be extended.

Full set of AVCs on a fresh F32 is the following. We don't need to allow rlimitinh and siginh, they aren't really required, according to my testing with a custom policy:

type=AVC msg=audit(1593698019.970:2915): avc:  denied  { noatsecure } for  pid=33476 comm="oddjobd" scontext=system_u:system_r:oddjob_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ipa_helper_t:s0 tclass=process permissive=1
type=AVC msg=audit(1593698019.971:2916): avc:  denied  { rlimitinh } for  pid=33476 comm="com.redhat.idm." scontext=system_u:system_r:oddjob_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ipa_helper_t:s0 tclass=process permissive=1
type=AVC msg=audit(1593698019.971:2917): avc:  denied  { siginh } for  pid=33476 comm="com.redhat.idm." scontext=system_u:system_r:oddjob_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ipa_helper_t:s0 tclass=process permissive=1
type=AVC msg=audit(1593698022.000:2918): avc:  denied  { read } for  pid=33479 comm="ipa-getkeytab" name="config" dev="vda1" ino=156614 scontext=system_u:system_r:ipa_helper_t:s0 tcontext=system_u:object_r:selinux_config_t:s0 tclass=file permissive=1
type=AVC msg=audit(1593698022.001:2919): avc:  denied  { open } for  pid=33479 comm="ipa-getkeytab" path="/etc/selinux/config" dev="vda1" ino=156614 scontext=system_u:system_r:ipa_helper_t:s0 tcontext=system_u:object_r:selinux_config_t:s0 tclass=file permissive=1
type=AVC msg=audit(1593698022.001:2920): avc:  denied  { getattr } for  pid=33479 comm="ipa-getkeytab" path="/etc/selinux/config" dev="vda1" ino=156614 scontext=system_u:system_r:ipa_helper_t:s0 tcontext=system_u:object_r:selinux_config_t:s0 tclass=file permissive=1

@abbra
Copy link
Contributor Author

abbra commented Jul 2, 2020

SELinux policy change: fedora-selinux/selinux-policy-contrib#292

@abbra abbra force-pushed the fix-trust-selinux-policy branch from ad374e9 to f5fe5ae Compare July 2, 2020 14:59
@zpytela
Copy link
Contributor

zpytela commented Jul 2, 2020

selinux-policy counterpart:
fedora-selinux/selinux-policy-contrib#293

On Fedora 32+ and RHEL 8.3.0+ execution of ipa_helper_t context requires
SELinux policy permission to use 'noatsecure'. This comes most likely
from execve() setup by glibc.

Add SELinux interface ipa_helper_noatsecure() that can be called by
oddjob's SELinux policy definition.

In addition, if ipa_helper_t runs ipa-getkeytab, libkrb5 will attempt to
access SELinux configuration and produce AVC for that. Allow reading
general userspace SELinux configuration.

Fixes: https://pagure.io/freeipa/issue/8395
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
@abbra abbra force-pushed the fix-trust-selinux-policy branch from f5fe5ae to ac74c40 Compare July 3, 2020 11:52
Related: https://pagure.io/freeipa/issue/8395
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
@abbra abbra force-pushed the fix-trust-selinux-policy branch from e7ee1be to 343212b Compare July 3, 2020 14:54
@abbra abbra added the ipa-4-8 Mark for backport to ipa 4.8 label Jul 6, 2020
Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

SELinux team agrees with the changeset. 👍

@tiran tiran added the ack Pull Request approved, can be merged label Jul 6, 2020
@abbra abbra added the pushed Pull Request has already been pushed label Jul 6, 2020
@abbra
Copy link
Contributor Author

abbra commented Jul 6, 2020

master:

  • f6055e6 selinux: allow oddjobd to set up ipa_helper_t context for execution
  • 91713f4 selinux: support running ipa-custodia with PrivateTmp=yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged ipa-4-8 Mark for backport to ipa 4.8 pushed Pull Request has already been pushed
Projects
None yet
3 participants