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 6/8] netns: introduce netns_get_inum()
Date: Mon, 18 Mar 2013 11:45:45 -0400	[thread overview]
Message-ID: <1363621547-25239-7-git-send-email-arozansk@redhat.com> (raw)
In-Reply-To: <1363621547-25239-1-git-send-email-arozansk@redhat.com>

This allows other parts of the kernel to have access to userspace
visible namespace identification.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
---
 include/net/net_namespace.h |    1 +
 net/core/net_namespace.c    |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index de644bc..bb24cf4 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -134,6 +134,7 @@ extern struct net init_net;
 #ifdef CONFIG_NET_NS
 extern struct net *copy_net_ns(unsigned long flags,
 	struct user_namespace *user_ns, struct net *old_net);
+extern unsigned int netns_get_inum(struct task_struct *tsk);
 
 #else /* CONFIG_NET_NS */
 #include <linux/sched.h>
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 80e271d..76c89e5 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -664,6 +664,20 @@ static unsigned int netns_inum(void *ns)
 	return net->proc_inum;
 }
 
+unsigned int netns_get_inum(struct task_struct *tsk)
+{
+	struct nsproxy *nsproxy;
+	unsigned int rc = 0;
+
+	rcu_read_lock();
+	nsproxy = task_nsproxy(tsk);
+	if (nsproxy)
+		rc = netns_inum(nsproxy->net_ns);
+	rcu_read_unlock();
+
+	return rc;
+}
+
 const struct proc_ns_operations netns_operations = {
 	.name		= "net",
 	.type		= CLONE_NEWNET,
-- 
1.7.1

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

Thread overview: 9+ 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 ` Aristeu Rozanski [this message]
2013-03-18 15:45 ` [PATCH RFC 7/8] audit: report namespace information along with USER events Aristeu Rozanski
2013-03-18 15:45 ` [PATCH RFC 8/8] audit: allow user records to be created inside a container Aristeu Rozanski

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-7-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