This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
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 2140726 - Audit rules for /proc are not loaded on boot
Summary: Audit rules for /proc are not loaded on boot
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: audit
Version: 9.0
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Sergio Correia
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-07 18:45 UTC by Juan Gamba
Modified: 2023-09-19 17:35 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-19 17:35:11 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github linux-audit/audit-userspace/commit/2f631c32 0 None None None 2022-11-08 16:31:30 UTC
Red Hat Issue Tracker   RHEL-5197 0 None Migrated None 2023-09-19 17:35:14 UTC
Red Hat Issue Tracker RHELPLAN-138562 0 None None None 2022-11-07 19:03:14 UTC
Red Hat Issue Tracker SECENGSP-4866 0 None None None 2022-11-07 19:03:18 UTC

Description Juan Gamba 2022-11-07 18:45:44 UTC
Description of problem:

Audit rules for "-F dir=/proc" fails to load on boot, the rules works if loaded manually later.
This behavior differs from RHEL 7 (the rules for /proc are loaded correctly on boot)

Version-Release number of selected component (if applicable):

audit-3.0.7-101.el9_0.2.x86_64

How reproducible:

Always

Steps to Reproduce:
1. # vi /etc/audit/rules.d/test.rules
-a never,exit -F arch=b32 -F dir=/proc -S fchmodat
2. # reboot
3. # auditctl -l

Actual results:

# auditctl -l
No rules.

Expected results:

# auditctl -l
-a never,exit -F arch=b32 -S fchmodat -F dir=/proc 

Additional info:

The list of syscalls is actually quite extensive, the same behavior occurs with any syscall we tested, it does not occur if we use a different "-F dir=" value, this behavior is only present on /proc so far.
Another detail, if we run auditd with -f, we can see below log record on system boot's journal:

auditd[xxx]: type=CONFIG_CHANGE msg=audit(xxxxxxxxxx.xxx:xxx): op=remove_rule dir="/proc" key=(null) list=4 res=1

Juan Gamba
Principal Technical Support Engineer
Red Hat - Support Delivery

Comment 1 Steve Grubb 2022-11-07 20:19:31 UTC
auditd is probably starting before procfs is mounted.

Comment 2 Juan Gamba 2022-11-07 20:38:27 UTC
is this a kernel problem then?
I saw it on RHEL 8 as well.

Comment 3 Steve Grubb 2022-11-07 20:45:59 UTC
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.

Comment 4 Renaud Métrich 2022-11-08 14:12:59 UTC
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< --------

Comment 5 Steve Grubb 2022-11-08 15:15:19 UTC
Thanks for that hint. Upstream commit 2f631c32 should fix this. And fortunately, the customer can make a change in /etc to override this.

Comment 6 Renaud Métrich 2022-11-08 15:25:04 UTC
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.

Comment 7 Steve Grubb 2022-11-08 15:57:42 UTC
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.

Comment 8 Renaud Métrich 2022-11-08 16:04:33 UTC
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" ?

Comment 9 Steve Grubb 2022-11-08 16:12:39 UTC
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.

Comment 10 Renaud Métrich 2022-11-09 10:14:54 UTC
I understand, ideally then there should be decoupling between the two:
- auditd service
- audit rules loading

Comment 13 RHEL Program Management 2023-09-19 17:33:04 UTC
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.

Comment 14 RHEL Program Management 2023-09-19 17:35:11 UTC
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.


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