diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-23 20:01:20 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-15 00:47:55 -0400 |
commit | adb37c4c67f807f16beb222028fb3ce9a354dc2b (patch) | |
tree | 59f46f84b013f1a6390c72d58fe5b158c6e4b58e /fs/seq_file.c | |
parent | fc5795c8a94c2d0b221dffae9ebb22686b3dafd8 (diff) |
userns: Make seq_file's user namespace accessible
struct file already has a user namespace associated with it
in file->f_cred->user_ns, unfortunately because struct
seq_file has no struct file backpointer associated with
it, it is difficult to get at the user namespace in seq_file
context. Therefore add a helper function seq_user_ns to return
the associated user namespace and a user_ns field to struct
seq_file to be used in implementing seq_user_ns.
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 14cf9de1dbe1..99dffab4c4e4 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
10 | #include <linux/seq_file.h> | 10 | #include <linux/seq_file.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/cred.h> | ||
12 | 13 | ||
13 | #include <asm/uaccess.h> | 14 | #include <asm/uaccess.h> |
14 | #include <asm/page.h> | 15 | #include <asm/page.h> |
@@ -56,6 +57,9 @@ int seq_open(struct file *file, const struct seq_operations *op) | |||
56 | memset(p, 0, sizeof(*p)); | 57 | memset(p, 0, sizeof(*p)); |
57 | mutex_init(&p->lock); | 58 | mutex_init(&p->lock); |
58 | p->op = op; | 59 | p->op = op; |
60 | #ifdef CONFIG_USER_NS | ||
61 | p->user_ns = file->f_cred->user_ns; | ||
62 | #endif | ||
59 | 63 | ||
60 | /* | 64 | /* |
61 | * Wrappers around seq_open(e.g. swaps_open) need to be | 65 | * Wrappers around seq_open(e.g. swaps_open) need to be |