diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2006-10-02 05:18:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 10:57:20 -0400 |
commit | ab516013ad9ca47f1d3a936fa81303bfbf734d52 (patch) | |
tree | 643ea9c4c3d28958cb42dd87b1856f74edd22b11 | |
parent | b1ba4ddde0cf67991d89f039365eaaeda61aa027 (diff) |
[PATCH] namespaces: add nsproxy
This patch adds a nsproxy structure to the task struct. Later patches will
move the fs namespace pointer into this structure, and introduce a new utsname
namespace into the nsproxy.
The vserver and openvz functionality, then, would be implemented in large part
by virtualizing/isolating more and more resources into namespaces, each
contained in the nsproxy.
[akpm@osdl.org: build fix]
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Cc: Kirill Korotaev <dev@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Andrey Savochkin <saw@sw.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
27 files changed, 196 insertions, 2 deletions
diff --git a/arch/alpha/kernel/init_task.c b/arch/alpha/kernel/init_task.c index 835d09a7b332..83d09021ed97 100644 --- a/arch/alpha/kernel/init_task.c +++ b/arch/alpha/kernel/init_task.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init_task.h> | 5 | #include <linux/init_task.h> |
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/mqueue.h> | 7 | #include <linux/mqueue.h> |
8 | #include <linux/nsproxy.h> | ||
8 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
9 | 10 | ||
10 | 11 | ||
@@ -13,6 +14,7 @@ static struct files_struct init_files = INIT_FILES; | |||
13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
15 | struct mm_struct init_mm = INIT_MM(init_mm); | 16 | struct mm_struct init_mm = INIT_MM(init_mm); |
17 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
16 | struct task_struct init_task = INIT_TASK(init_task); | 18 | struct task_struct init_task = INIT_TASK(init_task); |
17 | 19 | ||
18 | EXPORT_SYMBOL(init_mm); | 20 | EXPORT_SYMBOL(init_mm); |
diff --git a/arch/arm/kernel/init_task.c b/arch/arm/kernel/init_task.c index a00cca0000bd..80f5eeb6d3a8 100644 --- a/arch/arm/kernel/init_task.c +++ b/arch/arm/kernel/init_task.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/init_task.h> | 9 | #include <linux/init_task.h> |
10 | #include <linux/mqueue.h> | 10 | #include <linux/mqueue.h> |
11 | #include <linux/nsproxy.h> | ||
11 | 12 | ||
12 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
13 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
@@ -17,6 +18,7 @@ static struct files_struct init_files = INIT_FILES; | |||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 18 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 19 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 20 | struct mm_struct init_mm = INIT_MM(init_mm); |
21 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
20 | 22 | ||
21 | EXPORT_SYMBOL(init_mm); | 23 | EXPORT_SYMBOL(init_mm); |
22 | 24 | ||
diff --git a/arch/arm26/kernel/init_task.c b/arch/arm26/kernel/init_task.c index 4191565b889b..678c7b57f9c7 100644 --- a/arch/arm26/kernel/init_task.c +++ b/arch/arm26/kernel/init_task.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/init_task.h> | 12 | #include <linux/init_task.h> |
13 | #include <linux/mqueue.h> | 13 | #include <linux/mqueue.h> |
14 | #include <linux/nsproxy.h> | ||
14 | 15 | ||
15 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
16 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
@@ -20,6 +21,7 @@ static struct files_struct init_files = INIT_FILES; | |||
20 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
21 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
22 | struct mm_struct init_mm = INIT_MM(init_mm); | 23 | struct mm_struct init_mm = INIT_MM(init_mm); |
24 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
23 | 25 | ||
24 | EXPORT_SYMBOL(init_mm); | 26 | EXPORT_SYMBOL(init_mm); |
25 | 27 | ||
diff --git a/arch/frv/kernel/init_task.c b/arch/frv/kernel/init_task.c index 22993932b3fc..5ec27422bfe3 100644 --- a/arch/frv/kernel/init_task.c +++ b/arch/frv/kernel/init_task.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init_task.h> | 5 | #include <linux/init_task.h> |
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/mqueue.h> | 7 | #include <linux/mqueue.h> |
8 | #include <linux/nsproxy.h> | ||
8 | 9 | ||
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
10 | #include <asm/pgtable.h> | 11 | #include <asm/pgtable.h> |
@@ -15,6 +16,7 @@ static struct files_struct init_files = INIT_FILES; | |||
15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
17 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
19 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
18 | 20 | ||
19 | EXPORT_SYMBOL(init_mm); | 21 | EXPORT_SYMBOL(init_mm); |
20 | 22 | ||
diff --git a/arch/h8300/kernel/init_task.c b/arch/h8300/kernel/init_task.c index 19272c2ac56a..ef5755af6e28 100644 --- a/arch/h8300/kernel/init_task.c +++ b/arch/h8300/kernel/init_task.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/init_task.h> | 8 | #include <linux/init_task.h> |
9 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
10 | #include <linux/mqueue.h> | 10 | #include <linux/mqueue.h> |
11 | #include <linux/nsproxy.h> | ||
11 | 12 | ||
12 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
13 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
@@ -17,6 +18,7 @@ static struct files_struct init_files = INIT_FILES; | |||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 18 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 19 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 20 | struct mm_struct init_mm = INIT_MM(init_mm); |
21 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
20 | 22 | ||
21 | EXPORT_SYMBOL(init_mm); | 23 | EXPORT_SYMBOL(init_mm); |
22 | 24 | ||
diff --git a/arch/i386/kernel/init_task.c b/arch/i386/kernel/init_task.c index cff95d10a4d8..bd97f69ac34f 100644 --- a/arch/i386/kernel/init_task.c +++ b/arch/i386/kernel/init_task.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init_task.h> | 5 | #include <linux/init_task.h> |
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/mqueue.h> | 7 | #include <linux/mqueue.h> |
8 | #include <linux/nsproxy.h> | ||
8 | 9 | ||
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
10 | #include <asm/pgtable.h> | 11 | #include <asm/pgtable.h> |
@@ -15,6 +16,7 @@ static struct files_struct init_files = INIT_FILES; | |||
15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
17 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
19 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
18 | 20 | ||
19 | EXPORT_SYMBOL(init_mm); | 21 | EXPORT_SYMBOL(init_mm); |
20 | 22 | ||
diff --git a/arch/ia64/kernel/init_task.c b/arch/ia64/kernel/init_task.c index b69c397ed1bf..2d62471bfd02 100644 --- a/arch/ia64/kernel/init_task.c +++ b/arch/ia64/kernel/init_task.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/init_task.h> | 13 | #include <linux/init_task.h> |
14 | #include <linux/mqueue.h> | 14 | #include <linux/mqueue.h> |
15 | #include <linux/nsproxy.h> | ||
15 | 16 | ||
16 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
17 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
@@ -21,6 +22,7 @@ static struct files_struct init_files = INIT_FILES; | |||
21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 22 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 23 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
23 | struct mm_struct init_mm = INIT_MM(init_mm); | 24 | struct mm_struct init_mm = INIT_MM(init_mm); |
25 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
24 | 26 | ||
25 | EXPORT_SYMBOL(init_mm); | 27 | EXPORT_SYMBOL(init_mm); |
26 | 28 | ||
diff --git a/arch/m32r/kernel/init_task.c b/arch/m32r/kernel/init_task.c index 9e508fd9d970..005747590da6 100644 --- a/arch/m32r/kernel/init_task.c +++ b/arch/m32r/kernel/init_task.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/init_task.h> | 7 | #include <linux/init_task.h> |
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | #include <linux/mqueue.h> | 9 | #include <linux/mqueue.h> |
10 | #include <linux/nsproxy.h> | ||
10 | 11 | ||
11 | #include <asm/uaccess.h> | 12 | #include <asm/uaccess.h> |
12 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable.h> |
@@ -16,6 +17,7 @@ static struct files_struct init_files = INIT_FILES; | |||
16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
18 | struct mm_struct init_mm = INIT_MM(init_mm); | 19 | struct mm_struct init_mm = INIT_MM(init_mm); |
20 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
19 | 21 | ||
20 | EXPORT_SYMBOL(init_mm); | 22 | EXPORT_SYMBOL(init_mm); |
21 | 23 | ||
diff --git a/arch/m68knommu/kernel/init_task.c b/arch/m68knommu/kernel/init_task.c index 3897043a126a..b99fc6d6b7c1 100644 --- a/arch/m68knommu/kernel/init_task.c +++ b/arch/m68knommu/kernel/init_task.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/init_task.h> | 8 | #include <linux/init_task.h> |
9 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
10 | #include <linux/mqueue.h> | 10 | #include <linux/mqueue.h> |
11 | #include <linux/nsproxy.h> | ||
11 | 12 | ||
12 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
13 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
@@ -17,6 +18,7 @@ static struct files_struct init_files = INIT_FILES; | |||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 18 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 19 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 20 | struct mm_struct init_mm = INIT_MM(init_mm); |
21 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
20 | 22 | ||
21 | EXPORT_SYMBOL(init_mm); | 23 | EXPORT_SYMBOL(init_mm); |
22 | 24 | ||
diff --git a/arch/mips/kernel/init_task.c b/arch/mips/kernel/init_task.c index aeda7f58391b..dfe47e6a8b37 100644 --- a/arch/mips/kernel/init_task.c +++ b/arch/mips/kernel/init_task.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/init_task.h> | 4 | #include <linux/init_task.h> |
5 | #include <linux/fs.h> | 5 | #include <linux/fs.h> |
6 | #include <linux/mqueue.h> | 6 | #include <linux/mqueue.h> |
7 | #include <linux/nsproxy.h> | ||
7 | 8 | ||
8 | #include <asm/thread_info.h> | 9 | #include <asm/thread_info.h> |
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
@@ -14,6 +15,7 @@ static struct files_struct init_files = INIT_FILES; | |||
14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
16 | struct mm_struct init_mm = INIT_MM(init_mm); | 17 | struct mm_struct init_mm = INIT_MM(init_mm); |
18 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
17 | 19 | ||
18 | EXPORT_SYMBOL(init_mm); | 20 | EXPORT_SYMBOL(init_mm); |
19 | 21 | ||
diff --git a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c index 8384bf9cecd2..c0c43e29973b 100644 --- a/arch/parisc/kernel/init_task.c +++ b/arch/parisc/kernel/init_task.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/init_task.h> | 29 | #include <linux/init_task.h> |
30 | #include <linux/mqueue.h> | 30 | #include <linux/mqueue.h> |
31 | #include <linux/nsproxy.h> | ||
31 | 32 | ||
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
33 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
@@ -38,6 +39,7 @@ static struct files_struct init_files = INIT_FILES; | |||
38 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 39 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
39 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 40 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
40 | struct mm_struct init_mm = INIT_MM(init_mm); | 41 | struct mm_struct init_mm = INIT_MM(init_mm); |
42 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
41 | 43 | ||
42 | EXPORT_SYMBOL(init_mm); | 44 | EXPORT_SYMBOL(init_mm); |
43 | 45 | ||
diff --git a/arch/powerpc/kernel/init_task.c b/arch/powerpc/kernel/init_task.c index 941043ae040f..e24ace618987 100644 --- a/arch/powerpc/kernel/init_task.c +++ b/arch/powerpc/kernel/init_task.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init_task.h> | 5 | #include <linux/init_task.h> |
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/mqueue.h> | 7 | #include <linux/mqueue.h> |
8 | #include <linux/nsproxy.h> | ||
8 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
9 | 10 | ||
10 | static struct fs_struct init_fs = INIT_FS; | 11 | static struct fs_struct init_fs = INIT_FS; |
@@ -12,6 +13,7 @@ static struct files_struct init_files = INIT_FILES; | |||
12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
14 | struct mm_struct init_mm = INIT_MM(init_mm); | 15 | struct mm_struct init_mm = INIT_MM(init_mm); |
16 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
15 | 17 | ||
16 | EXPORT_SYMBOL(init_mm); | 18 | EXPORT_SYMBOL(init_mm); |
17 | 19 | ||
diff --git a/arch/s390/kernel/init_task.c b/arch/s390/kernel/init_task.c index d73a74013e73..0918921763b1 100644 --- a/arch/s390/kernel/init_task.c +++ b/arch/s390/kernel/init_task.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/init_task.h> | 12 | #include <linux/init_task.h> |
13 | #include <linux/mqueue.h> | 13 | #include <linux/mqueue.h> |
14 | #include <linux/nsproxy.h> | ||
14 | 15 | ||
15 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
16 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
@@ -20,6 +21,7 @@ static struct files_struct init_files = INIT_FILES; | |||
20 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
21 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
22 | struct mm_struct init_mm = INIT_MM(init_mm); | 23 | struct mm_struct init_mm = INIT_MM(init_mm); |
24 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
23 | 25 | ||
24 | EXPORT_SYMBOL(init_mm); | 26 | EXPORT_SYMBOL(init_mm); |
25 | 27 | ||
diff --git a/arch/sh/kernel/init_task.c b/arch/sh/kernel/init_task.c index 44053ea92936..81caf0fd3bee 100644 --- a/arch/sh/kernel/init_task.c +++ b/arch/sh/kernel/init_task.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/sched.h> | 3 | #include <linux/sched.h> |
4 | #include <linux/init_task.h> | 4 | #include <linux/init_task.h> |
5 | #include <linux/mqueue.h> | 5 | #include <linux/mqueue.h> |
6 | #include <linux/nsproxy.h> | ||
6 | 7 | ||
7 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
8 | #include <asm/pgtable.h> | 9 | #include <asm/pgtable.h> |
@@ -12,6 +13,7 @@ static struct files_struct init_files = INIT_FILES; | |||
12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
14 | struct mm_struct init_mm = INIT_MM(init_mm); | 15 | struct mm_struct init_mm = INIT_MM(init_mm); |
16 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
15 | 17 | ||
16 | EXPORT_SYMBOL(init_mm); | 18 | EXPORT_SYMBOL(init_mm); |
17 | 19 | ||
diff --git a/arch/sh64/kernel/init_task.c b/arch/sh64/kernel/init_task.c index de2d07db1f88..0c95f40c5403 100644 --- a/arch/sh64/kernel/init_task.c +++ b/arch/sh64/kernel/init_task.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/init_task.h> | 15 | #include <linux/init_task.h> |
16 | #include <linux/mqueue.h> | 16 | #include <linux/mqueue.h> |
17 | #include <linux/nsproxy.h> | ||
17 | 18 | ||
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
19 | #include <asm/pgtable.h> | 20 | #include <asm/pgtable.h> |
@@ -23,6 +24,7 @@ static struct files_struct init_files = INIT_FILES; | |||
23 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 24 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
24 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 25 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
25 | struct mm_struct init_mm = INIT_MM(init_mm); | 26 | struct mm_struct init_mm = INIT_MM(init_mm); |
27 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
26 | 28 | ||
27 | struct pt_regs fake_swapper_regs; | 29 | struct pt_regs fake_swapper_regs; |
28 | 30 | ||
diff --git a/arch/sparc/kernel/init_task.c b/arch/sparc/kernel/init_task.c index fc31de66b1c2..a73926d5176b 100644 --- a/arch/sparc/kernel/init_task.c +++ b/arch/sparc/kernel/init_task.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/sched.h> | 3 | #include <linux/sched.h> |
4 | #include <linux/init_task.h> | 4 | #include <linux/init_task.h> |
5 | #include <linux/mqueue.h> | 5 | #include <linux/mqueue.h> |
6 | #include <linux/nsproxy.h> | ||
6 | 7 | ||
7 | #include <asm/pgtable.h> | 8 | #include <asm/pgtable.h> |
8 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
@@ -12,6 +13,7 @@ static struct files_struct init_files = INIT_FILES; | |||
12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
14 | struct mm_struct init_mm = INIT_MM(init_mm); | 15 | struct mm_struct init_mm = INIT_MM(init_mm); |
16 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
15 | struct task_struct init_task = INIT_TASK(init_task); | 17 | struct task_struct init_task = INIT_TASK(init_task); |
16 | 18 | ||
17 | EXPORT_SYMBOL(init_mm); | 19 | EXPORT_SYMBOL(init_mm); |
diff --git a/arch/sparc64/kernel/init_task.c b/arch/sparc64/kernel/init_task.c index 329b38fa5c89..f1e9a4b021ae 100644 --- a/arch/sparc64/kernel/init_task.c +++ b/arch/sparc64/kernel/init_task.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/sched.h> | 3 | #include <linux/sched.h> |
4 | #include <linux/init_task.h> | 4 | #include <linux/init_task.h> |
5 | #include <linux/mqueue.h> | 5 | #include <linux/mqueue.h> |
6 | #include <linux/nsproxy.h> | ||
6 | 7 | ||
7 | #include <asm/pgtable.h> | 8 | #include <asm/pgtable.h> |
8 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
@@ -13,6 +14,7 @@ static struct files_struct init_files = INIT_FILES; | |||
13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
15 | struct mm_struct init_mm = INIT_MM(init_mm); | 16 | struct mm_struct init_mm = INIT_MM(init_mm); |
17 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
16 | 18 | ||
17 | EXPORT_SYMBOL(init_mm); | 19 | EXPORT_SYMBOL(init_mm); |
18 | 20 | ||
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c index 49ed5ddf0704..11188af64d86 100644 --- a/arch/um/kernel/init_task.c +++ b/arch/um/kernel/init_task.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "linux/sched.h" | 9 | #include "linux/sched.h" |
10 | #include "linux/init_task.h" | 10 | #include "linux/init_task.h" |
11 | #include "linux/mqueue.h" | 11 | #include "linux/mqueue.h" |
12 | #include "linux/nsproxy.h" | ||
12 | #include "asm/uaccess.h" | 13 | #include "asm/uaccess.h" |
13 | #include "asm/pgtable.h" | 14 | #include "asm/pgtable.h" |
14 | #include "user_util.h" | 15 | #include "user_util.h" |
@@ -17,6 +18,7 @@ | |||
17 | 18 | ||
18 | static struct fs_struct init_fs = INIT_FS; | 19 | static struct fs_struct init_fs = INIT_FS; |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 20 | struct mm_struct init_mm = INIT_MM(init_mm); |
21 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
20 | static struct files_struct init_files = INIT_FILES; | 22 | static struct files_struct init_files = INIT_FILES; |
21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 23 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 24 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
diff --git a/arch/v850/kernel/init_task.c b/arch/v850/kernel/init_task.c index ed2f93cf7c66..9d2de7590849 100644 --- a/arch/v850/kernel/init_task.c +++ b/arch/v850/kernel/init_task.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/init_task.h> | 16 | #include <linux/init_task.h> |
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/mqueue.h> | 18 | #include <linux/mqueue.h> |
19 | #include <linux/nsproxy.h> | ||
19 | 20 | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | #include <asm/pgtable.h> | 22 | #include <asm/pgtable.h> |
@@ -25,6 +26,7 @@ static struct files_struct init_files = INIT_FILES; | |||
25 | static struct signal_struct init_signals = INIT_SIGNALS (init_signals); | 26 | static struct signal_struct init_signals = INIT_SIGNALS (init_signals); |
26 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 27 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
27 | struct mm_struct init_mm = INIT_MM (init_mm); | 28 | struct mm_struct init_mm = INIT_MM (init_mm); |
29 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
28 | 30 | ||
29 | EXPORT_SYMBOL(init_mm); | 31 | EXPORT_SYMBOL(init_mm); |
30 | 32 | ||
diff --git a/arch/x86_64/kernel/init_task.c b/arch/x86_64/kernel/init_task.c index 3dc5854ba21e..879728bff73f 100644 --- a/arch/x86_64/kernel/init_task.c +++ b/arch/x86_64/kernel/init_task.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/init_task.h> | 5 | #include <linux/init_task.h> |
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/mqueue.h> | 7 | #include <linux/mqueue.h> |
8 | #include <linux/nsproxy.h> | ||
8 | 9 | ||
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
10 | #include <asm/pgtable.h> | 11 | #include <asm/pgtable.h> |
@@ -15,6 +16,7 @@ static struct files_struct init_files = INIT_FILES; | |||
15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
17 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
19 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | ||
18 | 20 | ||
19 | EXPORT_SYMBOL(init_mm); | 21 | EXPORT_SYMBOL(init_mm); |
20 | 22 | ||
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 60aac2cea0cf..8f8bb422a5c7 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -68,6 +68,12 @@ | |||
68 | .session = 1, \ | 68 | .session = 1, \ |
69 | } | 69 | } |
70 | 70 | ||
71 | extern struct nsproxy init_nsproxy; | ||
72 | #define INIT_NSPROXY(nsproxy) { \ | ||
73 | .count = ATOMIC_INIT(1), \ | ||
74 | .nslock = SPIN_LOCK_UNLOCKED, \ | ||
75 | } | ||
76 | |||
71 | #define INIT_SIGHAND(sighand) { \ | 77 | #define INIT_SIGHAND(sighand) { \ |
72 | .count = ATOMIC_INIT(1), \ | 78 | .count = ATOMIC_INIT(1), \ |
73 | .action = { { { .sa_handler = NULL, } }, }, \ | 79 | .action = { { { .sa_handler = NULL, } }, }, \ |
@@ -117,6 +123,7 @@ extern struct group_info init_groups; | |||
117 | .files = &init_files, \ | 123 | .files = &init_files, \ |
118 | .signal = &init_signals, \ | 124 | .signal = &init_signals, \ |
119 | .sighand = &init_sighand, \ | 125 | .sighand = &init_sighand, \ |
126 | .nsproxy = &init_nsproxy, \ | ||
120 | .pending = { \ | 127 | .pending = { \ |
121 | .list = LIST_HEAD_INIT(tsk.pending.list), \ | 128 | .list = LIST_HEAD_INIT(tsk.pending.list), \ |
122 | .signal = {{0}}}, \ | 129 | .signal = {{0}}}, \ |
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h new file mode 100644 index 000000000000..7bdebfaab6a5 --- /dev/null +++ b/include/linux/nsproxy.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef _LINUX_NSPROXY_H | ||
2 | #define _LINUX_NSPROXY_H | ||
3 | |||
4 | #include <linux/spinlock.h> | ||
5 | #include <linux/sched.h> | ||
6 | |||
7 | /* | ||
8 | * A structure to contain pointers to all per-process | ||
9 | * namespaces - fs (mount), uts, network, sysvipc, etc. | ||
10 | * | ||
11 | * 'count' is the number of tasks holding a reference. | ||
12 | * The count for each namespace, then, will be the number | ||
13 | * of nsproxies pointing to it, not the number of tasks. | ||
14 | * | ||
15 | * The nsproxy is shared by tasks which share all namespaces. | ||
16 | * As soon as a single namespace is cloned or unshared, the | ||
17 | * nsproxy is copied. | ||
18 | */ | ||
19 | struct nsproxy { | ||
20 | atomic_t count; | ||
21 | spinlock_t nslock; | ||
22 | }; | ||
23 | extern struct nsproxy init_nsproxy; | ||
24 | |||
25 | struct nsproxy *dup_namespaces(struct nsproxy *orig); | ||
26 | int copy_namespaces(int flags, struct task_struct *tsk); | ||
27 | void get_task_namespaces(struct task_struct *tsk); | ||
28 | void free_nsproxy(struct nsproxy *ns); | ||
29 | |||
30 | static inline void put_nsproxy(struct nsproxy *ns) | ||
31 | { | ||
32 | if (atomic_dec_and_test(&ns->count)) { | ||
33 | free_nsproxy(ns); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | static inline void exit_task_namespaces(struct task_struct *p) | ||
38 | { | ||
39 | struct nsproxy *ns = p->nsproxy; | ||
40 | if (ns) { | ||
41 | put_nsproxy(ns); | ||
42 | p->nsproxy = NULL; | ||
43 | } | ||
44 | } | ||
45 | #endif | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index a7fff3304bd6..4fa631fa55e3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -239,6 +239,7 @@ extern signed long schedule_timeout_uninterruptible(signed long timeout); | |||
239 | asmlinkage void schedule(void); | 239 | asmlinkage void schedule(void); |
240 | 240 | ||
241 | struct namespace; | 241 | struct namespace; |
242 | struct nsproxy; | ||
242 | 243 | ||
243 | /* Maximum number of active map areas.. This is a random (large) number */ | 244 | /* Maximum number of active map areas.. This is a random (large) number */ |
244 | #define DEFAULT_MAX_MAP_COUNT 65536 | 245 | #define DEFAULT_MAX_MAP_COUNT 65536 |
@@ -898,6 +899,7 @@ struct task_struct { | |||
898 | struct files_struct *files; | 899 | struct files_struct *files; |
899 | /* namespace */ | 900 | /* namespace */ |
900 | struct namespace *namespace; | 901 | struct namespace *namespace; |
902 | struct nsproxy *nsproxy; | ||
901 | /* signal handlers */ | 903 | /* signal handlers */ |
902 | struct signal_struct *signal; | 904 | struct signal_struct *signal; |
903 | struct sighand_struct *sighand; | 905 | struct sighand_struct *sighand; |
diff --git a/kernel/Makefile b/kernel/Makefile index aacaafb28b9d..6ec53009b866 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -8,7 +8,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ | |||
8 | signal.o sys.o kmod.o workqueue.o pid.o \ | 8 | signal.o sys.o kmod.o workqueue.o pid.o \ |
9 | rcupdate.o extable.o params.o posix-timers.o \ | 9 | rcupdate.o extable.o params.o posix-timers.o \ |
10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ | 10 | kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ |
11 | hrtimer.o rwsem.o latency.o | 11 | hrtimer.o rwsem.o latency.o nsproxy.o |
12 | 12 | ||
13 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | 13 | obj-$(CONFIG_STACKTRACE) += stacktrace.o |
14 | obj-y += time/ | 14 | obj-y += time/ |
diff --git a/kernel/exit.c b/kernel/exit.c index 3b47f26985f2..1d0e9ea1fa05 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/tsacct_kern.h> | 21 | #include <linux/tsacct_kern.h> |
22 | #include <linux/file.h> | 22 | #include <linux/file.h> |
23 | #include <linux/binfmts.h> | 23 | #include <linux/binfmts.h> |
24 | #include <linux/nsproxy.h> | ||
24 | #include <linux/ptrace.h> | 25 | #include <linux/ptrace.h> |
25 | #include <linux/profile.h> | 26 | #include <linux/profile.h> |
26 | #include <linux/mount.h> | 27 | #include <linux/mount.h> |
@@ -397,9 +398,14 @@ void daemonize(const char *name, ...) | |||
397 | fs = init_task.fs; | 398 | fs = init_task.fs; |
398 | current->fs = fs; | 399 | current->fs = fs; |
399 | atomic_inc(&fs->count); | 400 | atomic_inc(&fs->count); |
401 | |||
400 | exit_namespace(current); | 402 | exit_namespace(current); |
403 | exit_task_namespaces(current); | ||
401 | current->namespace = init_task.namespace; | 404 | current->namespace = init_task.namespace; |
405 | current->nsproxy = init_task.nsproxy; | ||
402 | get_namespace(current->namespace); | 406 | get_namespace(current->namespace); |
407 | get_task_namespaces(current); | ||
408 | |||
403 | exit_files(current); | 409 | exit_files(current); |
404 | current->files = init_task.files; | 410 | current->files = init_task.files; |
405 | atomic_inc(¤t->files->count); | 411 | atomic_inc(¤t->files->count); |
@@ -918,6 +924,7 @@ fastcall NORET_TYPE void do_exit(long code) | |||
918 | __exit_files(tsk); | 924 | __exit_files(tsk); |
919 | __exit_fs(tsk); | 925 | __exit_fs(tsk); |
920 | exit_namespace(tsk); | 926 | exit_namespace(tsk); |
927 | exit_task_namespaces(tsk); | ||
921 | exit_thread(); | 928 | exit_thread(); |
922 | cpuset_exit(tsk); | 929 | cpuset_exit(tsk); |
923 | exit_keys(tsk); | 930 | exit_keys(tsk); |
diff --git a/kernel/fork.c b/kernel/fork.c index 89f666491d1f..c9e660ae47aa 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/binfmts.h> | 27 | #include <linux/binfmts.h> |
28 | #include <linux/mman.h> | 28 | #include <linux/mman.h> |
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | #include <linux/nsproxy.h> | ||
30 | #include <linux/capability.h> | 31 | #include <linux/capability.h> |
31 | #include <linux/cpu.h> | 32 | #include <linux/cpu.h> |
32 | #include <linux/cpuset.h> | 33 | #include <linux/cpuset.h> |
@@ -1116,8 +1117,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1116 | goto bad_fork_cleanup_signal; | 1117 | goto bad_fork_cleanup_signal; |
1117 | if ((retval = copy_keys(clone_flags, p))) | 1118 | if ((retval = copy_keys(clone_flags, p))) |
1118 | goto bad_fork_cleanup_mm; | 1119 | goto bad_fork_cleanup_mm; |
1119 | if ((retval = copy_namespace(clone_flags, p))) | 1120 | if ((retval = copy_namespaces(clone_flags, p))) |
1120 | goto bad_fork_cleanup_keys; | 1121 | goto bad_fork_cleanup_keys; |
1122 | if ((retval = copy_namespace(clone_flags, p))) | ||
1123 | goto bad_fork_cleanup_namespaces; | ||
1121 | retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); | 1124 | retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); |
1122 | if (retval) | 1125 | if (retval) |
1123 | goto bad_fork_cleanup_namespace; | 1126 | goto bad_fork_cleanup_namespace; |
@@ -1262,6 +1265,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1262 | 1265 | ||
1263 | bad_fork_cleanup_namespace: | 1266 | bad_fork_cleanup_namespace: |
1264 | exit_namespace(p); | 1267 | exit_namespace(p); |
1268 | bad_fork_cleanup_namespaces: | ||
1269 | exit_task_namespaces(p); | ||
1265 | bad_fork_cleanup_keys: | 1270 | bad_fork_cleanup_keys: |
1266 | exit_keys(p); | 1271 | exit_keys(p); |
1267 | bad_fork_cleanup_mm: | 1272 | bad_fork_cleanup_mm: |
@@ -1606,6 +1611,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) | |||
1606 | struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; | 1611 | struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; |
1607 | struct files_struct *fd, *new_fd = NULL; | 1612 | struct files_struct *fd, *new_fd = NULL; |
1608 | struct sem_undo_list *new_ulist = NULL; | 1613 | struct sem_undo_list *new_ulist = NULL; |
1614 | struct nsproxy *new_nsproxy, *old_nsproxy; | ||
1609 | 1615 | ||
1610 | check_unshare_flags(&unshare_flags); | 1616 | check_unshare_flags(&unshare_flags); |
1611 | 1617 | ||
@@ -1632,7 +1638,15 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) | |||
1632 | 1638 | ||
1633 | if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist) { | 1639 | if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist) { |
1634 | 1640 | ||
1641 | old_nsproxy = current->nsproxy; | ||
1642 | new_nsproxy = dup_namespaces(old_nsproxy); | ||
1643 | if (!new_nsproxy) { | ||
1644 | err = -ENOMEM; | ||
1645 | goto bad_unshare_cleanup_semundo; | ||
1646 | } | ||
1647 | |||
1635 | task_lock(current); | 1648 | task_lock(current); |
1649 | current->nsproxy = new_nsproxy; | ||
1636 | 1650 | ||
1637 | if (new_fs) { | 1651 | if (new_fs) { |
1638 | fs = current->fs; | 1652 | fs = current->fs; |
@@ -1668,8 +1682,10 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) | |||
1668 | } | 1682 | } |
1669 | 1683 | ||
1670 | task_unlock(current); | 1684 | task_unlock(current); |
1685 | put_nsproxy(old_nsproxy); | ||
1671 | } | 1686 | } |
1672 | 1687 | ||
1688 | bad_unshare_cleanup_semundo: | ||
1673 | bad_unshare_cleanup_fd: | 1689 | bad_unshare_cleanup_fd: |
1674 | if (new_fd) | 1690 | if (new_fd) |
1675 | put_files_struct(new_fd); | 1691 | put_files_struct(new_fd); |
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c new file mode 100644 index 000000000000..ad9508865473 --- /dev/null +++ b/kernel/nsproxy.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 IBM Corporation | ||
3 | * | ||
4 | * Author: Serge Hallyn <serue@us.ibm.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation, version 2 of the | ||
9 | * License. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/version.h> | ||
14 | #include <linux/nsproxy.h> | ||
15 | |||
16 | static inline void get_nsproxy(struct nsproxy *ns) | ||
17 | { | ||
18 | atomic_inc(&ns->count); | ||
19 | } | ||
20 | |||
21 | void get_task_namespaces(struct task_struct *tsk) | ||
22 | { | ||
23 | struct nsproxy *ns = tsk->nsproxy; | ||
24 | if (ns) { | ||
25 | get_nsproxy(ns); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | /* | ||
30 | * creates a copy of "orig" with refcount 1. | ||
31 | * This does not grab references to the contained namespaces, | ||
32 | * so that needs to be done by dup_namespaces. | ||
33 | */ | ||
34 | static inline struct nsproxy *clone_namespaces(struct nsproxy *orig) | ||
35 | { | ||
36 | struct nsproxy *ns; | ||
37 | |||
38 | ns = kmalloc(sizeof(struct nsproxy), GFP_KERNEL); | ||
39 | if (ns) { | ||
40 | memcpy(ns, orig, sizeof(struct nsproxy)); | ||
41 | atomic_set(&ns->count, 1); | ||
42 | } | ||
43 | return ns; | ||
44 | } | ||
45 | |||
46 | /* | ||
47 | * copies the nsproxy, setting refcount to 1, and grabbing a | ||
48 | * reference to all contained namespaces. Called from | ||
49 | * sys_unshare() | ||
50 | */ | ||
51 | struct nsproxy *dup_namespaces(struct nsproxy *orig) | ||
52 | { | ||
53 | struct nsproxy *ns = clone_namespaces(orig); | ||
54 | |||
55 | return ns; | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * called from clone. This now handles copy for nsproxy and all | ||
60 | * namespaces therein. | ||
61 | */ | ||
62 | int copy_namespaces(int flags, struct task_struct *tsk) | ||
63 | { | ||
64 | struct nsproxy *old_ns = tsk->nsproxy; | ||
65 | |||
66 | if (!old_ns) | ||
67 | return 0; | ||
68 | |||
69 | get_nsproxy(old_ns); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | void free_nsproxy(struct nsproxy *ns) | ||
75 | { | ||
76 | kfree(ns); | ||
77 | } | ||