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 /include/linux | |
| 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 'include/linux')
| -rw-r--r-- | include/linux/seq_file.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 83c44eefe698..68a04a343cad 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
| @@ -13,6 +13,7 @@ struct file; | |||
| 13 | struct path; | 13 | struct path; |
| 14 | struct inode; | 14 | struct inode; |
| 15 | struct dentry; | 15 | struct dentry; |
| 16 | struct user_namespace; | ||
| 16 | 17 | ||
| 17 | struct seq_file { | 18 | struct seq_file { |
| 18 | char *buf; | 19 | char *buf; |
| @@ -25,6 +26,9 @@ struct seq_file { | |||
| 25 | struct mutex lock; | 26 | struct mutex lock; |
| 26 | const struct seq_operations *op; | 27 | const struct seq_operations *op; |
| 27 | int poll_event; | 28 | int poll_event; |
| 29 | #ifdef CONFIG_USER_NS | ||
| 30 | struct user_namespace *user_ns; | ||
| 31 | #endif | ||
| 28 | void *private; | 32 | void *private; |
| 29 | }; | 33 | }; |
| 30 | 34 | ||
| @@ -128,6 +132,16 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter, | |||
| 128 | int seq_put_decimal_ll(struct seq_file *m, char delimiter, | 132 | int seq_put_decimal_ll(struct seq_file *m, char delimiter, |
| 129 | long long num); | 133 | long long num); |
| 130 | 134 | ||
| 135 | static inline struct user_namespace *seq_user_ns(struct seq_file *seq) | ||
| 136 | { | ||
| 137 | #ifdef CONFIG_USER_NS | ||
| 138 | return seq->user_ns; | ||
| 139 | #else | ||
| 140 | extern struct user_namespace init_user_ns; | ||
| 141 | return &init_user_ns; | ||
| 142 | #endif | ||
| 143 | } | ||
| 144 | |||
| 131 | #define SEQ_START_TOKEN ((void *)1) | 145 | #define SEQ_START_TOKEN ((void *)1) |
| 132 | /* | 146 | /* |
| 133 | * Helpers for iteration over list_head-s in seq_files | 147 | * Helpers for iteration over list_head-s in seq_files |
