mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 23:04:43 +00:00
ns: proc files for namespace naming policy.
Create files under /proc/<pid>/ns/ to allow controlling the namespaces of a process. This addresses three specific problems that can make namespaces hard to work with. - Namespaces require a dedicated process to pin them in memory. - It is not possible to use a namespace unless you are the child of the original creator. - Namespaces don't have names that userspace can use to talk about them. The namespace files under /proc/<pid>/ns/ can be opened and the file descriptor can be used to talk about a specific namespace, and to keep the specified namespace alive. A namespace can be kept alive by either holding the file descriptor open or bind mounting the file someplace else. aka: mount --bind /proc/self/ns/net /some/filesystem/path mount --bind /proc/self/fd/<N> /some/filesystem/path This allows namespaces to be named with userspace policy. It requires additional support to make use of these filedescriptors and that will be comming in the following patches. Acked-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
0ee5623f9a
commit
6b4e306aa3
6 changed files with 241 additions and 11 deletions
|
@ -179,6 +179,8 @@ extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
|
|||
extern struct file *get_mm_exe_file(struct mm_struct *mm);
|
||||
extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
|
||||
|
||||
extern struct file *proc_ns_fget(int fd);
|
||||
|
||||
#else
|
||||
|
||||
#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; })
|
||||
|
@ -239,6 +241,11 @@ static inline void dup_mm_exe_file(struct mm_struct *oldmm,
|
|||
struct mm_struct *newmm)
|
||||
{}
|
||||
|
||||
static inline struct file *proc_ns_fget(int fd)
|
||||
{
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
|
||||
#if !defined(CONFIG_PROC_KCORE)
|
||||
|
@ -250,6 +257,15 @@ kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
|
|||
extern void kclist_add(struct kcore_list *, void *, size_t, int type);
|
||||
#endif
|
||||
|
||||
struct nsproxy;
|
||||
struct proc_ns_operations {
|
||||
const char *name;
|
||||
int type;
|
||||
void *(*get)(struct task_struct *task);
|
||||
void (*put)(void *ns);
|
||||
int (*install)(struct nsproxy *nsproxy, void *ns);
|
||||
};
|
||||
|
||||
union proc_op {
|
||||
int (*proc_get_link)(struct inode *, struct path *);
|
||||
int (*proc_read)(struct task_struct *task, char *page);
|
||||
|
@ -268,6 +284,8 @@ struct proc_inode {
|
|||
struct proc_dir_entry *pde;
|
||||
struct ctl_table_header *sysctl;
|
||||
struct ctl_table *sysctl_entry;
|
||||
void *ns;
|
||||
const struct proc_ns_operations *ns_ops;
|
||||
struct inode vfs_inode;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue