public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Aristeu Rozanski <arozansk@redhat.com>
To: linux-audit@redhat.com
Subject: [PATCH RFC 8/8] audit: allow user records to be created inside a container
Date: Mon, 18 Mar 2013 11:45:47 -0400	[thread overview]
Message-ID: <1363621547-25239-9-git-send-email-arozansk@redhat.com> (raw)
In-Reply-To: <1363621547-25239-1-git-send-email-arozansk@redhat.com>

Since user events will be followed by namespace information, userspace
can filter off undesired container records.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
---
 kernel/audit.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index b17f9c0..cc6ffc9 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -570,6 +570,23 @@ out:
 	kfree(reply);
 }
 
+static int audit_namespace_check(struct task_struct *tsk, u16 msg_type)
+{
+	/* USER messages are allowed from inside containers */
+	switch (msg_type) {
+	case AUDIT_USER:
+	case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
+	case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
+		return 1;
+	default:
+		if ((current_user_ns() != &init_user_ns) ||
+		    (task_active_pid_ns(current) != &init_pid_ns))
+			return 0;
+		break;
+	}
+	return 1;
+}
+
 /*
  * Check for appropriate CAP_AUDIT_ capabilities on incoming audit
  * control messages.
@@ -578,9 +595,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
 {
 	int err = 0;
 
-	/* Only support the initial namespaces for now. */
-	if ((current_user_ns() != &init_user_ns) ||
-	    (task_active_pid_ns(current) != &init_pid_ns))
+	if (!audit_namespace_check(current, msg_type))
 		return -EPERM;
 
 	switch (msg_type) {
@@ -597,13 +612,13 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
 	case AUDIT_TTY_SET:
 	case AUDIT_TRIM:
 	case AUDIT_MAKE_EQUIV:
-		if (!capable(CAP_AUDIT_CONTROL))
+		if (!nsown_capable(CAP_AUDIT_CONTROL))
 			err = -EPERM;
 		break;
 	case AUDIT_USER:
 	case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
 	case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
-		if (!capable(CAP_AUDIT_WRITE))
+		if (!nsown_capable(CAP_AUDIT_WRITE))
 			err = -EPERM;
 		break;
 	default:  /* bad msg */
-- 
1.7.1

  parent reply	other threads:[~2013-03-18 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 15:45 [PATCH RFC] audit: provide namespace information in user originated records Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 1/8] mntns: introduce mntns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 2/8] ipcns: introduce ipcns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 3/8] pidns: introduce pidns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 4/8] userns: introduce userns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 5/8] utsns: introduce utsns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 6/8] netns: introduce netns_get_inum() Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 7/8] audit: report namespace information along with USER events Aristeu Rozanski
2013-03-18 15:45 ` Aristeu Rozanski [this message]
     [not found] <1363619405-6419-1-git-send-email-arozansk@redhat.com>
     [not found] ` <1363619405-6419-9-git-send-email-arozansk@redhat.com>
2013-03-18 21:28   ` [PATCH RFC 8/8] audit: allow user records to be created inside a container Eric W. Biederman

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=1363621547-25239-9-git-send-email-arozansk@redhat.com \
    --to=arozansk@redhat.com \
    --cc=linux-audit@redhat.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