mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 10:49:28 +00:00
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>
This commit is contained in:
parent
fc5795c8a9
commit
adb37c4c67
2 changed files with 18 additions and 0 deletions
|
@ -13,6 +13,7 @@ struct file;
|
|||
struct path;
|
||||
struct inode;
|
||||
struct dentry;
|
||||
struct user_namespace;
|
||||
|
||||
struct seq_file {
|
||||
char *buf;
|
||||
|
@ -25,6 +26,9 @@ struct seq_file {
|
|||
struct mutex lock;
|
||||
const struct seq_operations *op;
|
||||
int poll_event;
|
||||
#ifdef CONFIG_USER_NS
|
||||
struct user_namespace *user_ns;
|
||||
#endif
|
||||
void *private;
|
||||
};
|
||||
|
||||
|
@ -128,6 +132,16 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
|
|||
int seq_put_decimal_ll(struct seq_file *m, char delimiter,
|
||||
long long num);
|
||||
|
||||
static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
|
||||
{
|
||||
#ifdef CONFIG_USER_NS
|
||||
return seq->user_ns;
|
||||
#else
|
||||
extern struct user_namespace init_user_ns;
|
||||
return &init_user_ns;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SEQ_START_TOKEN ((void *)1)
|
||||
/*
|
||||
* Helpers for iteration over list_head-s in seq_files
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue