Linux 5.9 Released14 Oct 2020 tags: audit selinux
Linux v5.9 was released on Sunday, October 11th, 2020; the SELinux and audit highlights are below:
- Allow reading of SELinux labels before the policy is loaded, allowing for some more “exotic” initramfs approaches as described by the author Jonathan Lebon:
This patch does for ‘getxattr’ what commit 3e3e24b42043 (“selinux: allow labeling before policy is loaded”) did for ‘setxattr’; it allows querying the current SELinux label on disk before the policy is loaded.
One of the motivations described in that commit message also drives this patch: for Fedora CoreOS (and eventually RHEL CoreOS), we want to be able to move the root filesystem for example, from xfs to ext4 on RAID, on first boot, at initrd time.
Because such an operation works at the filesystem level, we need to be able to read the SELinux labels first from the original root, and apply them to the files of the new root. The previous commit enabled the second part of this process; this commit enables the first part.
- Improved the SELinux policy symbol table performance due to a rework of the insert and search functions. The patch author, Ondrej Mosnacek, described the impact of the changes in the commit description:
With this patch, I measured a speed up in the following areas (measured on x86_64 F32 VM with 4 CPUs):
- Policy load (‘load_policy’) - takes ~150 ms instead of ~230 ms.
- ‘chcon -R unconfined_u:object_r:user_tmp_t:s0:c381,c519 /tmp/linux-src’ where /tmp/linux-src is an extracted linux-5.7 source tarball - takes ~522 ms instead of ~576 ms. This is because of many symtab_search() calls in string_to_context_struct() when there are many categories specified in the context.
- ‘stress-ng –msg 1 –msg-ops 10000000’ - takes 12.41 s instead of 13.95 s (consumes 18.6 s of kernel CPU time instead of 21.6 s). This is thanks to security_transition_sid() being ~43% faster after this patch.
Added support for the CAP_CHECKPOINT_RESTORE capability in the “capability2” object class as “checkpoint_restore”.
Fixed a problem where error messages were not properly logged when the required “process” object class, “transition” permission, or “dyntransition” permission were missing from the policy being loaded into the kernel.
- Fix some problems with initial SIDs and the script generated SELinux MDP policy.
- Audit records are now generated for nftables configuration change events using the NETFILTER_CFG record with the “table” field carrying the nftables name and handle information as seen in this example record provided by the patch author, Richard Guy Briggs:
type=NETFILTER_CFG msg=audit(2020-05-28 17:46:41.911:163) : table=firewalld:1;filter_FORWARD:85 family=inet entries=101 op=nft_register_rule pid=396 subj=system_u:system_r:firewalld_t:s0 comm=firewalld
- Add a new backlog wait metric to the audit status message, this is intended to help admins determine how long processes have been waiting for the audit backlog queue to clear. The patch author, Max Englander, describes this in more detail in the commit description:
In environments where the preservation of audit events and predictable usage of system memory are prioritized, admins may use a combination of –backlog_wait_time and -b options at the risk of degraded performance resulting from backlog waiting. In some cases, this risk may be preferred to lost events or unbounded memory usage. Ideally, this risk can be mitigated by making adjustments when backlog waiting is detected.
However, detection can be difficult using the currently available metrics. For example, an admin attempting to debug degraded performance may falsely believe a full backlog indicates backlog waiting. It may turn out the backlog frequently fills up but drains quickly.
To make it easier to reliably track degraded performance to backlog waiting, this patch makes the following changes:
Add a new field backlog_wait_time_total to the audit status reply. Initialize this field to zero. Add to this field the total time spent by the current task on scheduled timeouts while the backlog limit is exceeded. Reset field to zero upon request via AUDIT_SET.
Fixed a problem where the LSM_AUDIT_DATA_* records were not causing the CWD record to be generated. Prior to this fix, administrators could find it difficult to piece together a complete audit event in some situations.
- Several small internal kernel fixes and removal of old, outdated code.