Commit 038cbcf6 authored by Eric Paris's avatar Eric Paris Committed by Al Viro

Audit: unify the printk of an skb when auditd not around

Remove code duplication of skb printk when auditd is not around in userspace
to deal with this message.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent e85188f4
...@@ -375,6 +375,25 @@ static void audit_hold_skb(struct sk_buff *skb) ...@@ -375,6 +375,25 @@ static void audit_hold_skb(struct sk_buff *skb)
kfree_skb(skb); kfree_skb(skb);
} }
/*
* For one reason or another this nlh isn't getting delivered to the userspace
* audit daemon, just send it to printk.
*/
static void audit_printk_skb(struct sk_buff *skb)
{
struct nlmsghdr *nlh = nlmsg_hdr(skb);
char *data = NLMSG_DATA(nlh);
if (nlh->nlmsg_type != AUDIT_EOE) {
if (printk_ratelimit())
printk(KERN_NOTICE "type=%d %s\n", nlh->nlmsg_type, data);
else
audit_log_lost("printk limit exceeded\n");
}
audit_hold_skb(skb);
}
static void kauditd_send_skb(struct sk_buff *skb) static void kauditd_send_skb(struct sk_buff *skb)
{ {
int err; int err;
...@@ -427,14 +446,8 @@ static int kauditd_thread(void *dummy) ...@@ -427,14 +446,8 @@ static int kauditd_thread(void *dummy)
if (skb) { if (skb) {
if (audit_pid) if (audit_pid)
kauditd_send_skb(skb); kauditd_send_skb(skb);
else {
if (printk_ratelimit())
printk(KERN_NOTICE "%s\n", skb->data + NLMSG_SPACE(0));
else else
audit_log_lost("printk limit exceeded\n"); audit_printk_skb(skb);
audit_hold_skb(skb);
}
} else { } else {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -1475,15 +1488,7 @@ void audit_log_end(struct audit_buffer *ab) ...@@ -1475,15 +1488,7 @@ void audit_log_end(struct audit_buffer *ab)
skb_queue_tail(&audit_skb_queue, ab->skb); skb_queue_tail(&audit_skb_queue, ab->skb);
wake_up_interruptible(&kauditd_wait); wake_up_interruptible(&kauditd_wait);
} else { } else {
if (nlh->nlmsg_type != AUDIT_EOE) { audit_printk_skb(ab->skb);
if (printk_ratelimit()) {
printk(KERN_NOTICE "type=%d %s\n",
nlh->nlmsg_type,
ab->skb->data + NLMSG_SPACE(0));
} else
audit_log_lost("printk limit exceeded\n");
}
audit_hold_skb(ab->skb);
} }
ab->skb = NULL; ab->skb = NULL;
} }
......
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