Skip to content

Commit 6c54e78

Browse files
committed
audit: handle a clean auditd shutdown with grace
When auditd stops cleanly it sets 'auditd_pid' to 0 with an AUDIT_SET message, in this case we should reset our backlog queues via the auditd_reset() function. This patch also adds a 'auditd_pid' check to the top of kauditd_send_unicast_skb() so we can fail quicker. Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent e1d1662 commit 6c54e78

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎kernel/audit.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ static int kauditd_send_unicast_skb(struct sk_buff *skb)
468468
{
469469
int rc;
470470

471+
/* if we know nothing is connected, don't even try the netlink call */
472+
if (!audit_pid)
473+
return -ECONNREFUSED;
474+
471475
/* get an extra skb reference in case we fail to send */
472476
skb_get(skb);
473477
rc = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
@@ -1009,6 +1013,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
10091013
audit_pid = new_pid;
10101014
audit_nlk_portid = NETLINK_CB(skb).portid;
10111015
audit_sock = skb->sk;
1016+
if (!new_pid)
1017+
auditd_reset();
10121018
wake_up_interruptible(&kauditd_wait);
10131019
}
10141020
if (s.mask & AUDIT_STATUS_RATE_LIMIT) {

0 commit comments

Comments
 (0)