Skip to content

audit: remove audit_log_start() contention in AUDIT_USER type calls

Richard Guy Briggs linux-audit lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3selinux: call WARN_ONCE() instead of calling audit_log_start()security/selinux/ss/services.c+4 -80 replies
2/3smack: call WARN_ONCE() instead of calling audit_log_start()security/smack/smack_lsm.c+2 -32 replies
3/3audit: drop audit_cmd_lock in AUDIT_USER family of caseskernel/audit.c+2 -01 reply

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

Patch[email protected][email protected]
SeriesR-b
1/3
2/3
3/3T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] audit: remove audit_log_start() contention in AUDIT_USER type calls

There is a race condition between systemd and auditd:

systemd |auditd
-------------------------------------------+-----------------------------------

...                                        |
-> audit_receive                           |...
   -> mutex_lock(&audit_cmd_mutex)         |-> audit_receive
      ... -> audit_log_start               |   -> mutex_lock(&audit_cmd_mutex)
             -> wait_for_auditd            |      // wait for systemd
                -> schedule_timeout(60*HZ) |

This fix will take care of systemd and anything USING audit. It still means that we could race with something configuring audit and auditd shutting down.

The idea of dropping the lock at the top of audit_receive_msg() isn't as clean as I had hoped, with AUDIT_ADD_RULE, AUDIT_TRIM, AUDIT_MAKE_EQUIV all potentially allocating additional audit buffers indirectly through trim_marked(). It may make sense to have trim_marked() send its queue through a new thread.

Richard Guy Briggs (3):
selinux: call WARN_ONCE() instead of calling audit_log_start()
smack: call WARN_ONCE() instead of calling audit_log_start()
audit: drop audit_cmd_lock in AUDIT_USER family of cases

 kernel/audit.c                 |    2 ++
 security/selinux/ss/services.c |   12 ++++--------
 security/smack/smack_lsm.c     |    5 ++---
 3 files changed, 8 insertions(+), 11 deletions(-)