Bug 2140726
Summary: | Audit rules for /proc are not loaded on boot | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 9 | Reporter: | Juan Gamba <jgamba> |
Component: | audit | Assignee: | Sergio Correia <scorreia> |
Status: | CLOSED MIGRATED | QA Contact: | BaseOS QE Security Team <qe-baseos-security> |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 9.0 | CC: | alakatos, ravpatil, rmetrich, rsroka, sgrubb |
Target Milestone: | rc | Keywords: | MigratedToJIRA, Patch, Triaged |
Target Release: | --- | Flags: | pm-rhel:
mirror+
|
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2023-09-19 17:35:11 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Juan Gamba
2022-11-07 18:45:44 UTC
auditd is probably starting before procfs is mounted. is this a kernel problem then? I saw it on RHEL 8 as well. You'd need to test against RHEL 5 or 6 to see what the original behavior was. One solution I've is writing a udev rule that loads audit rules when something of interest comes along. The issue is easily reproducible, it's not only happening at boot, but when restarting auditd service. Manually adding the rule works. Digging more, I could find that it's due to the following property in the auditd service: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- ProtectControlGroups=true -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Example 1: (FAILS): -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- # systemctl cat load_audit.service # /etc/systemd/system/load_audit.service [Service] Type=oneshot ExecStartPre=/usr/sbin/auditctl -D ExecStart=/usr/sbin/auditctl -a never,exit -F arch=b64 -S fchmodat -F dir=/proc ProtectControlGroups=true -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Test: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- # systemctl restart load_audit.service # auditctl -l No rules -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Example 2: (without "ProtectControlGroups=true", WORKS): -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- # systemctl cat load_audit.service # /etc/systemd/system/load_audit.service [Service] Type=oneshot ExecStartPre=/usr/sbin/auditctl -D ExecStart=/usr/sbin/auditctl -a never,exit -F arch=b64 -S fchmodat -F dir=/proc #ProtectControlGroups=true -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Test: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- # systemctl restart load_audit.service # auditctl -l -a never,exit -F arch=b64 -S fchmodat -F dir=/proc -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- No error gets reported by auditctl command. So there is something happening in the kernel due to the protection above, but no error is returned through NETLINK layer. The straces are IDENTICAL, including returned data: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- sendto(4<NETLINK:[AUDIT:xxx]>, [{nlmsg_len=1064, nlmsg_type=AUDIT_ADD_RULE, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=2, nlmsg_pid=0}, "\x04\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"...], 1064, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 1064 poll([{fd=4<NETLINK:[AUDIT:xxx]>, events=POLLIN}], 1, 500) = 1 ([{fd=4, revents=POLLIN}]) recvfrom(4<NETLINK:[AUDIT:xxx]>, [{nlmsg_len=36, nlmsg_type=NLMSG_ERROR, nlmsg_flags=NLM_F_CAPPED, nlmsg_seq=2, nlmsg_pid=xxx}, {error=0, msg={nlmsg_len=1064, nlmsg_type=AUDIT_ADD_RULE, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=2, nlmsg_pid=0}}], 8988, MSG_PEEK|MSG_DONTWAIT, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, [12]) = 36 recvfrom(4<NETLINK:[AUDIT:xxx]>, [{nlmsg_len=36, nlmsg_type=NLMSG_ERROR, nlmsg_flags=NLM_F_CAPPED, nlmsg_seq=2, nlmsg_pid=xxx}, {error=0, msg={nlmsg_len=1064, nlmsg_type=AUDIT_ADD_RULE, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=2, nlmsg_pid=0}}], 8988, MSG_DONTWAIT, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, [12]) = 36 close(4<NETLINK:[AUDIT:xxx]>) = 0 exit_group(0) = ? -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Thanks for that hint. Upstream commit 2f631c32 should fix this. And fortunately, the customer can make a change in /etc to override this. Hi Steve, Can you explain why this doesn't work with that ProtectControlGroups=yes? All I see comparing the code in the kernel is the rule gets pruned for some reason, due to audit_tree_freeing_mark/audit_tree_destroy_watch being called after rule is added. Renaud. It appears that /proc gets remounted from auditd's perspective. So, the rule is likely placed on /proc that auditd sees and not the one in the init namespace. Indeed, I can see the remount of /proc through strace, following an unshare: 47649 16:31:11.484411 mount("proc", "/proc/self/fd/4", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL) = 0 <0.000036> Wouldn't it be possible to use an alternate mechanism than tag the "current mounts as seen by the service unit" ? Not that I know of except for separating rule loading from the auditd.service so that we have 2 services. One for rules and one for the daemon. But this is not the only systemd protection that has impacted the audit system. Well intentioned people submit pull requests asking for systemd protections which we later find out cause problems. I understand, ideally then there should be decoupling between the two: - auditd service - audit rules loading Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug. This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there. Due to differences in account names between systems, some fields were not replicated. Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information. To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer. You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like: "Bugzilla Bug" = 1234567 In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information. |