Commit 6c54e789 authored by Paul Moore's avatar Paul Moore

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: default avatarPaul Moore <paul@paul-moore.com>
parent e1d16621
...@@ -468,6 +468,10 @@ static int kauditd_send_unicast_skb(struct sk_buff *skb) ...@@ -468,6 +468,10 @@ static int kauditd_send_unicast_skb(struct sk_buff *skb)
{ {
int rc; int rc;
/* if we know nothing is connected, don't even try the netlink call */
if (!audit_pid)
return -ECONNREFUSED;
/* get an extra skb reference in case we fail to send */ /* get an extra skb reference in case we fail to send */
skb_get(skb); skb_get(skb);
rc = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0); 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) ...@@ -1009,6 +1013,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
audit_pid = new_pid; audit_pid = new_pid;
audit_nlk_portid = NETLINK_CB(skb).portid; audit_nlk_portid = NETLINK_CB(skb).portid;
audit_sock = skb->sk; audit_sock = skb->sk;
if (!new_pid)
auditd_reset();
wake_up_interruptible(&kauditd_wait); wake_up_interruptible(&kauditd_wait);
} }
if (s.mask & AUDIT_STATUS_RATE_LIMIT) { if (s.mask & AUDIT_STATUS_RATE_LIMIT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment