RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2124552 - SELinux prevents the sbd processes from readlink syscall { sys_ptrace }
Summary: SELinux prevents the sbd processes from readlink syscall { sys_ptrace }
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.7
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: 8.8
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-06 13:24 UTC by Michal Mazourek
Modified: 2023-05-16 11:02 UTC (History)
3 users (show)

Fixed In Version: selinux-policy-3.14.3-109.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 2124695 (view as bug list)
Environment:
Last Closed: 2023-05-16 09:04:16 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 1429 0 None open Allow sbd the sys_ptrace capability 2022-10-05 17:51:47 UTC
Red Hat Issue Tracker RHELPLAN-133313 0 None None None 2022-09-06 13:37:31 UTC
Red Hat Product Errata RHBA-2023:2965 0 None None None 2023-05-16 09:04:37 UTC

Comment 2 Zdenek Pytela 2022-09-09 14:21:07 UTC
This is the denial interpreted:

----
type=PROCTITLE msg=audit(09/01/2022 12:02:11.629:726) : proctitle=/usr/sbin/sbd query-watchdog
type=AVC msg=audit(09/01/2022 12:02:11.629:726) : avc:  denied  { sys_ptrace } for  pid=52395 comm=sbd capability=sys_ptrace  scontext=system_u:system_r:sbd_t:s0 tcontext=system_u:system_r:sbd_t:s0 tclass=capability permissive=0
type=SYSCALL msg=audit(09/01/2022 12:02:11.629:726) : arch=x86_64 syscall=readlink success=no exit=EACCES(Permission denied) a0=0x7ffe7787fa40 a1=0x7ffe7787f830 a2=0xff a3=0x0 items=0 ppid=52391 pid=52395 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=sbd exe=/usr/sbin/sbd subj=system_u:system_r:sbd_t:s0 key=(null)

It still misses some data which would appear when full auditing was enabled:

1) Open the /etc/audit/rules.d/audit.rules file in an editor.
2) Remove the following line if it exists:
-a task,never
3) Add the following line to the end of the file:
-w /etc/shadow -p w
4) Restart the audit daemon:
  # service auditd restart
5) Re-run your scenario.
6) Collect AVC denials:
  # ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts today

Comment 4 Zdenek Pytela 2022-09-12 13:35:25 UTC
Thank you, it is clearer now:
----
type=PROCTITLE msg=audit(09/12/2022 15:00:59.857:4015) : proctitle=/usr/sbin/sbd query-watchdog
type=PATH msg=audit(09/12/2022 15:00:59.857:4015) : item=0 name=/proc/851/fd/0 inode=21560 dev=00:05 mode=link,500 ouid=root ogid=root rdev=00:00 obj=system_u:system_r:rpcbind_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(09/12/2022 15:00:59.857:4015) : cwd=/var/lib/pcsd
type=SYSCALL msg=audit(09/12/2022 15:00:59.857:4015) : arch=x86_64 syscall=readlink success=no exit=EACCES(Permission denied) a0=0x7ffd9edd46c0 a1=0x7ffd9edd44b0 a2=0xff a3=0x0 items=1 ppid=538646 pid=538650 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=sbd exe=/usr/sbin/sbd subj=system_u:system_r:sbd_t:s0 key=(null)
type=AVC msg=audit(09/12/2022 15:00:59.857:4015) : avc:  denied  { sys_ptrace } for  pid=538650 comm=sbd capability=sys_ptrace  scontext=system_u:system_r:sbd_t:s0 tcontext=system_u:system_r:sbd_t:s0 tclass=capability permissive=0
----

Do you know which process has pid 851 or why does sbd want to access its file descriptors?

Can you check if the following permission is sufficient?

  # cat local_sbd_ptrace.cil
(allow sbd_t sbd_t (capability (sys_ptrace)))
  # semodule -i local_sbd_ptrace.cil

Comment 5 Michal Mazourek 2022-09-12 14:42:01 UTC
(In reply to Zdenek Pytela from comment #4)
> Thank you, it is clearer now:
> ----
> type=PROCTITLE msg=audit(09/12/2022 15:00:59.857:4015) :
> proctitle=/usr/sbin/sbd query-watchdog
> type=PATH msg=audit(09/12/2022 15:00:59.857:4015) : item=0
> name=/proc/851/fd/0 inode=21560 dev=00:05 mode=link,500 ouid=root ogid=root
> rdev=00:00 obj=system_u:system_r:rpcbind_t:s0 nametype=NORMAL cap_fp=none
> cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
> type=CWD msg=audit(09/12/2022 15:00:59.857:4015) : cwd=/var/lib/pcsd
> type=SYSCALL msg=audit(09/12/2022 15:00:59.857:4015) : arch=x86_64
> syscall=readlink success=no exit=EACCES(Permission denied) a0=0x7ffd9edd46c0
> a1=0x7ffd9edd44b0 a2=0xff a3=0x0 items=1 ppid=538646 pid=538650 auid=unset
> uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root
> fsgid=root tty=(none) ses=unset comm=sbd exe=/usr/sbin/sbd
> subj=system_u:system_r:sbd_t:s0 key=(null)
> type=AVC msg=audit(09/12/2022 15:00:59.857:4015) : avc:  denied  {
> sys_ptrace } for  pid=538650 comm=sbd capability=sys_ptrace 
> scontext=system_u:system_r:sbd_t:s0 tcontext=system_u:system_r:sbd_t:s0
> tclass=capability permissive=0
> ----
> 
> Do you know which process has pid 851 or why does sbd want to access its
> file descriptors?

The process with pid 851:
rpc          851  0.0  0.1  67240  5528 ?        Ss   Sep06   0:00 /usr/bin/rpcbind -w -f

I'm not sure about the sbd access to its file descriptors, Klaus will probably know more about it.


> Can you check if the following permission is sufficient?
> 
>   # cat local_sbd_ptrace.cil
> (allow sbd_t sbd_t (capability (sys_ptrace)))
>   # semodule -i local_sbd_ptrace.cil

The proposed permission seems to be sufficient, there were no new sbd avc denials after manual re-run run of the scenario.

Comment 6 Klaus Wenninger 2022-09-12 14:46:38 UTC
hmm ... thought I had tested that but not with the privileges of pcsd - which I guess is
happening here - but dropping the shell privileges ... maybe did something wrong there.

Reason for scanning over the fds is to check if the device was opened by
sbdy else - respectively who - similar as lsof would do.

Guess it does actually not matter which process has pid 851 in the test above.
Good news should be that apart from the AVC denials it should fall back to previous
behavior. And on the node the pcs command had been invoked it should work without
issues as it would usually be done in an interactive root shell.

Comment 7 Klaus Wenninger 2022-09-12 15:01:48 UTC
And I'm afraid there is not much I could do differently in sbd to achieve the
desired behavior. I mean besides taking back the feature.
Getting the identity of the watchdog-devices discovered would have failed
before that busy check. So in cases none of those had failed I could
skip the busy-check and thus prevent the AVC denials. In the cases the
implementation had been made for (sbdy is hogging the device) the
AVC denials would of course still be there.

Comment 8 Klaus Wenninger 2022-09-12 15:05:26 UTC
(In reply to Klaus Wenninger from comment #7)
> And I'm afraid there is not much I could do differently in sbd to achieve the
> desired behavior. I mean besides taking back the feature.
> Getting the identity of the watchdog-devices discovered would have failed
> before that busy check. So in cases none of those had failed I could
> skip the busy-check and thus prevent the AVC denials. In the cases the
> implementation had been made for (sbdy is hogging the device) the
> AVC denials would of course still be there.

But iirc there was a reason why I hadn't gone that route in the first
place. But I don't remember ...

Comment 12 Zdenek Pytela 2022-10-05 18:55:15 UTC
To backport:
commit 533de74a9a344542ab504915938b636698fd9838
Author: Zdenek Pytela <zpytela>
Date:   Wed Oct 5 14:12:22 2022 +0200

    Allow sbd the sys_ptrace capability

Comment 22 errata-xmlrpc 2023-05-16 09:04:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2965


Note You need to log in before you can comment on or make changes to this bug.