linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gao feng <gaofeng@cn.fujitsu.com>
To: linux-kernel@vger.kernel.org, linux-audit@redhat.com
Cc: containers@lists.linux-foundation.org, ebiederm@xmission.com,
	serge.hallyn@ubuntu.com, eparis@redhat.com, sgrubb@redhat.com,
	toshi.okajima@jp.fujitsu.com, Gao feng <gaofeng@cn.fujitsu.com>
Subject: [PATCH 12/20] audit: use proper audit_namespace in kauditd_thread
Date: Thu, 24 Oct 2013 15:31:57 +0800	[thread overview]
Message-ID: <1382599925-25143-13-git-send-email-gaofeng@cn.fujitsu.com> (raw)
In-Reply-To: <1382599925-25143-1-git-send-email-gaofeng@cn.fujitsu.com>

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 kernel/audit.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 5524deb..b203017 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -338,11 +338,11 @@ static int audit_set_failure(int state)
  * This only holds messages is audit_default is set, aka booting with audit=1
  * or building your kernel that way.
  */
-static void audit_hold_skb(struct sk_buff *skb)
+static void audit_hold_skb(struct audit_namespace *ns, struct sk_buff *skb)
 {
 	if (audit_default &&
-	    skb_queue_len(&init_audit_ns.hold_queue) < audit_backlog_limit)
-		skb_queue_tail(&init_audit_ns.hold_queue, skb);
+	    skb_queue_len(&ns->hold_queue) < audit_backlog_limit)
+		skb_queue_tail(&ns->hold_queue, skb);
 	else
 		kfree_skb(skb);
 }
@@ -351,7 +351,7 @@ static void audit_hold_skb(struct sk_buff *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)
+static void audit_printk_skb(struct audit_namespace *ns, struct sk_buff *skb)
 {
 	struct nlmsghdr *nlh = nlmsg_hdr(skb);
 	char *data = nlmsg_data(nlh);
@@ -363,22 +363,22 @@ static void audit_printk_skb(struct sk_buff *skb)
 			audit_log_lost("printk limit exceeded\n");
 	}
 
-	audit_hold_skb(skb);
+	audit_hold_skb(ns, skb);
 }
 
-static void kauditd_send_skb(struct sk_buff *skb)
+static void kauditd_send_skb(struct audit_namespace *ns, struct sk_buff *skb)
 {
 	int err;
 	/* take a reference in case we can't send it and we want to hold it */
 	skb_get(skb);
-	err = netlink_unicast(audit_sock, skb, init_audit_ns.portid, 0);
+	err = netlink_unicast(audit_sock, skb, ns->portid, 0);
 	if (err < 0) {
 		BUG_ON(err != -ECONNREFUSED); /* Shouldn't happen */
-		printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", init_audit_ns.pid);
+		printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", ns->pid);
 		audit_log_lost("auditd disappeared\n");
-		init_audit_ns.pid = 0;
+		ns->pid = 0;
 		/* we might get lucky and get this in the next auditd */
-		audit_hold_skb(skb);
+		audit_hold_skb(ns, skb);
 	} else
 		/* drop the extra reference if sent ok */
 		consume_skb(skb);
@@ -411,7 +411,7 @@ static void flush_hold_queue(struct audit_namespace *ns)
 		return;
 
 	while (skb && ns->pid) {
-		kauditd_send_skb(skb);
+		kauditd_send_skb(ns, skb);
 		skb = skb_dequeue(&ns->hold_queue);
 	}
 
@@ -441,16 +441,16 @@ static int kauditd_thread(void *dummy)
 		flush_hold_queue(ns);
 
 		skb = skb_dequeue(&ns->queue);
-		wake_up(&init_audit_ns.backlog_wait);
+		wake_up(&ns->backlog_wait);
 		if (skb) {
 			if (ns->pid)
-				kauditd_send_skb(skb);
+				kauditd_send_skb(ns, skb);
 			else
-				audit_printk_skb(skb);
+				audit_printk_skb(ns, skb);
 			continue;
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&init_audit_ns.kauditd_wait, &wait);
+		add_wait_queue(&ns->kauditd_wait, &wait);
 
 		if (!skb_queue_len(&ns->queue)) {
 			try_to_freeze();
@@ -458,7 +458,7 @@ static int kauditd_thread(void *dummy)
 		}
 
 		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&init_audit_ns.kauditd_wait, &wait);
+		remove_wait_queue(&ns->kauditd_wait, &wait);
 	}
 
 	ns->kauditd_task = NULL;
@@ -1713,7 +1713,7 @@ void audit_log_end(struct audit_buffer *ab)
 			skb_queue_tail(&init_audit_ns.queue, ab->skb);
 			wake_up_interruptible(&init_audit_ns.kauditd_wait);
 		} else {
-			audit_printk_skb(ab->skb);
+			audit_printk_skb(&init_audit_ns, ab->skb);
 		}
 		ab->skb = NULL;
 	}
-- 
1.8.3.1


  parent reply	other threads:[~2013-10-24  7:34 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24  7:31 [RFC Part1 PATCH 00/20 v2] Add namespace support for audit Gao feng
2013-10-24  7:31 ` [PATCH 01/20] Audit: make audit netlink socket net namespace unaware Gao feng
2013-10-24  7:31 ` [PATCH 02/20] audit: introduce configure option CONFIG_AUDIT_NS Gao feng
2013-10-24  7:31 ` [PATCH 03/20] audit: make audit_skb_queue per audit namespace Gao feng
2013-10-24  7:31 ` [PATCH 04/20] audit: make audit_skb_hold_queue " Gao feng
2013-10-24  7:31 ` [PATCH 05/20] audit: make audit_pid " Gao feng
2013-10-24  7:31 ` [PATCH 06/20] audit: make kauditd_task " Gao feng
2013-10-24  7:31 ` [PATCH 07/20] aduit: make audit_nlk_portid " Gao feng
2013-10-24  7:31 ` [PATCH 08/20] audit: make kaudit_wait queue " Gao feng
2013-10-24  7:31 ` [PATCH 09/20] audit: make audit_backlog_wait " Gao feng
2013-10-24  7:31 ` [PATCH 10/20] audit: allow un-init audit ns to change pid and portid only Gao feng
2013-10-24  7:31 ` [PATCH 11/20] audit: use proper audit namespace in audit_receive_msg Gao feng
2013-10-24  7:31 ` Gao feng [this message]
2013-10-24  7:31 ` [PATCH 13/20] audit: introduce new audit logging interface for audit namespace Gao feng
2013-10-24  7:31 ` [PATCH 14/20] audit: pass proper audit namespace to audit_log_common_recv_msg Gao feng
2013-10-24  7:32 ` [PATCH 15/20] audit: Log audit pid config change in audit namespace Gao feng
2013-10-24  7:32 ` [PATCH 16/20] audit: allow GET,SET,USER MSG operations " Gao feng
2013-12-06 22:00   ` [PATCH 16/20] audit: allow GET, SET, USER " Serge E. Hallyn
2013-12-09  1:47     ` Gao feng
2013-10-24  7:32 ` [PATCH 17/20] nsproxy: don't make create_new_namespaces static Gao feng
2013-10-24  7:32 ` [PATCH 18/20] audit: add new message type AUDIT_CREATE_NS Gao feng
2013-12-06 22:10   ` Serge E. Hallyn
2013-12-09  1:59     ` Gao feng
2013-12-09 17:53       ` Serge Hallyn
2013-12-10  5:34         ` Gao feng
2013-10-24  7:32 ` [PATCH 19/20] audit: make audit_backlog_limit per audit namespace Gao feng
2013-10-24  7:32 ` [PATCH 20/20] audit: introduce /proc/<pid>/audit_backlog_limit Gao feng
2013-10-31  3:52 ` [RFC Part1 PATCH 00/20 v2] Add namespace support for audit Gao feng
2013-11-05  7:51   ` Gao feng
2013-11-05  7:52     ` Gao feng
2013-11-05  8:11       ` Li Zefan
2013-11-05  8:56         ` Gao feng
2013-11-05 19:14           ` Richard Guy Briggs
2013-11-07  5:51             ` Gao feng
2013-11-21  7:57             ` Gao feng
2013-12-04  8:31 ` Gao feng
2013-12-06 22:12   ` Serge E. Hallyn
2013-12-09  2:06     ` Gao feng
2013-12-09 18:26       ` Serge Hallyn
2013-12-10  8:16         ` Gao feng
2013-12-10 16:51           ` Serge Hallyn
2013-12-10 19:50             ` Eric Paris
2013-12-10 20:36               ` Serge E. Hallyn
2013-12-16  3:39                 ` Gao feng
2013-12-20 21:15                   ` Serge E. Hallyn
2013-12-24  9:32                     ` Gao feng
2013-12-06 21:31 ` Serge E. Hallyn
2013-12-09  2:29   ` Gao feng
2013-12-23 23:47     ` Richard Guy Briggs
2013-12-24  9:53       ` Gao feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382599925-25143-13-git-send-email-gaofeng@cn.fujitsu.com \
    --to=gaofeng@cn.fujitsu.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=eparis@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@ubuntu.com \
    --cc=sgrubb@redhat.com \
    --cc=toshi.okajima@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).