diff options
33 files changed, 180 insertions, 192 deletions
diff --git a/arch/alpha/kernel/init_task.c b/arch/alpha/kernel/init_task.c index 835d09a7b332..1f762189fa64 100644 --- a/arch/alpha/kernel/init_task.c +++ b/arch/alpha/kernel/init_task.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | 10 | ||
11 | static struct fs_struct init_fs = INIT_FS; | 11 | static struct fs_struct init_fs = INIT_FS; |
12 | static struct files_struct init_files = INIT_FILES; | ||
13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
15 | struct mm_struct init_mm = INIT_MM(init_mm); | 14 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/arm/kernel/init_task.c b/arch/arm/kernel/init_task.c index bd4ef53bc6b9..8b8c9d38a761 100644 --- a/arch/arm/kernel/init_task.c +++ b/arch/arm/kernel/init_task.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable.h> |
14 | 14 | ||
15 | static struct fs_struct init_fs = INIT_FS; | 15 | static struct fs_struct init_fs = INIT_FS; |
16 | static struct files_struct init_files = INIT_FILES; | ||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/avr32/kernel/init_task.c b/arch/avr32/kernel/init_task.c index effcacf9d1a2..44058469c6ec 100644 --- a/arch/avr32/kernel/init_task.c +++ b/arch/avr32/kernel/init_task.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
15 | 15 | ||
16 | static struct fs_struct init_fs = INIT_FS; | 16 | static struct fs_struct init_fs = INIT_FS; |
17 | static struct files_struct init_files = INIT_FILES; | ||
18 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
19 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
20 | struct mm_struct init_mm = INIT_MM(init_mm); | 19 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/blackfin/kernel/init_task.c b/arch/blackfin/kernel/init_task.c index c640154030e2..6bdba7b21109 100644 --- a/arch/blackfin/kernel/init_task.c +++ b/arch/blackfin/kernel/init_task.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
35 | 35 | ||
36 | static struct fs_struct init_fs = INIT_FS; | 36 | static struct fs_struct init_fs = INIT_FS; |
37 | static struct files_struct init_files = INIT_FILES; | ||
38 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 37 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
39 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 38 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
40 | 39 | ||
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c index ef2db8fd102a..5933656db5a2 100644 --- a/arch/cris/kernel/process.c +++ b/arch/cris/kernel/process.c | |||
@@ -38,7 +38,6 @@ | |||
38 | */ | 38 | */ |
39 | 39 | ||
40 | static struct fs_struct init_fs = INIT_FS; | 40 | static struct fs_struct init_fs = INIT_FS; |
41 | static struct files_struct init_files = INIT_FILES; | ||
42 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 41 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
43 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 42 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
44 | struct mm_struct init_mm = INIT_MM(init_mm); | 43 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/frv/kernel/init_task.c b/arch/frv/kernel/init_task.c index 22993932b3fc..e2198815b630 100644 --- a/arch/frv/kernel/init_task.c +++ b/arch/frv/kernel/init_task.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | static struct fs_struct init_fs = INIT_FS; | 13 | static struct fs_struct init_fs = INIT_FS; |
14 | static struct files_struct init_files = INIT_FILES; | ||
15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
17 | struct mm_struct init_mm = INIT_MM(init_mm); | 16 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/h8300/kernel/init_task.c b/arch/h8300/kernel/init_task.c index 19272c2ac56a..93a4899e46c2 100644 --- a/arch/h8300/kernel/init_task.c +++ b/arch/h8300/kernel/init_task.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable.h> |
14 | 14 | ||
15 | static struct fs_struct init_fs = INIT_FS; | 15 | static struct fs_struct init_fs = INIT_FS; |
16 | static struct files_struct init_files = INIT_FILES; | ||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/ia64/kernel/init_task.c b/arch/ia64/kernel/init_task.c index bc8efcad28b8..9d7e1c66faf4 100644 --- a/arch/ia64/kernel/init_task.c +++ b/arch/ia64/kernel/init_task.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
19 | 19 | ||
20 | static struct fs_struct init_fs = INIT_FS; | 20 | static struct fs_struct init_fs = INIT_FS; |
21 | static struct files_struct init_files = INIT_FILES; | ||
22 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
23 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
24 | struct mm_struct init_mm = INIT_MM(init_mm); | 23 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/m32r/kernel/init_task.c b/arch/m32r/kernel/init_task.c index 9e508fd9d970..0d658dbb6766 100644 --- a/arch/m32r/kernel/init_task.c +++ b/arch/m32r/kernel/init_task.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <asm/pgtable.h> | 12 | #include <asm/pgtable.h> |
13 | 13 | ||
14 | static struct fs_struct init_fs = INIT_FS; | 14 | static struct fs_struct init_fs = INIT_FS; |
15 | static struct files_struct init_files = INIT_FILES; | ||
16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
18 | struct mm_struct init_mm = INIT_MM(init_mm); | 17 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index 5de4e4ed76ab..7888cdf91f5d 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c | |||
@@ -41,7 +41,6 @@ | |||
41 | * setup. | 41 | * setup. |
42 | */ | 42 | */ |
43 | static struct fs_struct init_fs = INIT_FS; | 43 | static struct fs_struct init_fs = INIT_FS; |
44 | static struct files_struct init_files = INIT_FILES; | ||
45 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 44 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
46 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 45 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
47 | struct mm_struct init_mm = INIT_MM(init_mm); | 46 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/m68knommu/kernel/init_task.c b/arch/m68knommu/kernel/init_task.c index 3897043a126a..344c01aede08 100644 --- a/arch/m68knommu/kernel/init_task.c +++ b/arch/m68knommu/kernel/init_task.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable.h> |
14 | 14 | ||
15 | static struct fs_struct init_fs = INIT_FS; | 15 | static struct fs_struct init_fs = INIT_FS; |
16 | static struct files_struct init_files = INIT_FILES; | ||
17 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
18 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
19 | struct mm_struct init_mm = INIT_MM(init_mm); | 18 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/mips/kernel/init_task.c b/arch/mips/kernel/init_task.c index aeda7f58391b..d72487ad7c15 100644 --- a/arch/mips/kernel/init_task.c +++ b/arch/mips/kernel/init_task.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <asm/pgtable.h> | 10 | #include <asm/pgtable.h> |
11 | 11 | ||
12 | static struct fs_struct init_fs = INIT_FS; | 12 | static struct fs_struct init_fs = INIT_FS; |
13 | static struct files_struct init_files = INIT_FILES; | ||
14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
16 | struct mm_struct init_mm = INIT_MM(init_mm); | 15 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/mn10300/kernel/init_task.c b/arch/mn10300/kernel/init_task.c index 39fe6882dd1d..af16f6e5c918 100644 --- a/arch/mn10300/kernel/init_task.c +++ b/arch/mn10300/kernel/init_task.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <asm/pgtable.h> | 19 | #include <asm/pgtable.h> |
20 | 20 | ||
21 | static struct fs_struct init_fs = INIT_FS; | 21 | static struct fs_struct init_fs = INIT_FS; |
22 | static struct files_struct init_files = INIT_FILES; | ||
23 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 22 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
24 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 23 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
25 | struct mm_struct init_mm = INIT_MM(init_mm); | 24 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c index 26198a074d67..f5941c086551 100644 --- a/arch/parisc/kernel/init_task.c +++ b/arch/parisc/kernel/init_task.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <asm/pgalloc.h> | 35 | #include <asm/pgalloc.h> |
36 | 36 | ||
37 | static struct fs_struct init_fs = INIT_FS; | 37 | static struct fs_struct init_fs = INIT_FS; |
38 | static struct files_struct init_files = INIT_FILES; | ||
39 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 38 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
40 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 39 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
41 | struct mm_struct init_mm = INIT_MM(init_mm); | 40 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/powerpc/kernel/init_task.c b/arch/powerpc/kernel/init_task.c index 941043ae040f..4c85b8d56478 100644 --- a/arch/powerpc/kernel/init_task.c +++ b/arch/powerpc/kernel/init_task.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
9 | 9 | ||
10 | static struct fs_struct init_fs = INIT_FS; | 10 | static struct fs_struct init_fs = INIT_FS; |
11 | static struct files_struct init_files = INIT_FILES; | ||
12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 11 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 12 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
14 | struct mm_struct init_mm = INIT_MM(init_mm); | 13 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/s390/kernel/init_task.c b/arch/s390/kernel/init_task.c index d494161b05b4..7ad003969251 100644 --- a/arch/s390/kernel/init_task.c +++ b/arch/s390/kernel/init_task.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
18 | 18 | ||
19 | static struct fs_struct init_fs = INIT_FS; | 19 | static struct fs_struct init_fs = INIT_FS; |
20 | static struct files_struct init_files = INIT_FILES; | ||
21 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 20 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
22 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 21 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
23 | struct mm_struct init_mm = INIT_MM(init_mm); | 22 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/sh/kernel/init_task.c b/arch/sh/kernel/init_task.c index f9bcc606127e..b151a25cb14d 100644 --- a/arch/sh/kernel/init_task.c +++ b/arch/sh/kernel/init_task.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <asm/pgtable.h> | 8 | #include <asm/pgtable.h> |
9 | 9 | ||
10 | static struct fs_struct init_fs = INIT_FS; | 10 | static struct fs_struct init_fs = INIT_FS; |
11 | static struct files_struct init_files = INIT_FILES; | ||
12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 11 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 12 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
14 | struct pt_regs fake_swapper_regs; | 13 | struct pt_regs fake_swapper_regs; |
diff --git a/arch/sparc/kernel/init_task.c b/arch/sparc/kernel/init_task.c index d9d4f96360c7..8e64ebc445ef 100644 --- a/arch/sparc/kernel/init_task.c +++ b/arch/sparc/kernel/init_task.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <asm/uaccess.h> | 9 | #include <asm/uaccess.h> |
10 | 10 | ||
11 | static struct fs_struct init_fs = INIT_FS; | 11 | static struct fs_struct init_fs = INIT_FS; |
12 | static struct files_struct init_files = INIT_FILES; | ||
13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 12 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 13 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
15 | struct mm_struct init_mm = INIT_MM(init_mm); | 14 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/sparc64/kernel/init_task.c b/arch/sparc64/kernel/init_task.c index 90007cf88bac..d2b312381c19 100644 --- a/arch/sparc64/kernel/init_task.c +++ b/arch/sparc64/kernel/init_task.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <asm/processor.h> | 10 | #include <asm/processor.h> |
11 | 11 | ||
12 | static struct fs_struct init_fs = INIT_FS; | 12 | static struct fs_struct init_fs = INIT_FS; |
13 | static struct files_struct init_files = INIT_FILES; | ||
14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 13 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 14 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
16 | struct mm_struct init_mm = INIT_MM(init_mm); | 15 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c index dcfceca95052..910eda8fca18 100644 --- a/arch/um/kernel/init_task.c +++ b/arch/um/kernel/init_task.c | |||
@@ -12,7 +12,6 @@ | |||
12 | 12 | ||
13 | static struct fs_struct init_fs = INIT_FS; | 13 | static struct fs_struct init_fs = INIT_FS; |
14 | struct mm_struct init_mm = INIT_MM(init_mm); | 14 | struct mm_struct init_mm = INIT_MM(init_mm); |
15 | static struct files_struct init_files = INIT_FILES; | ||
16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
18 | EXPORT_SYMBOL(init_mm); | 17 | EXPORT_SYMBOL(init_mm); |
diff --git a/arch/v850/kernel/init_task.c b/arch/v850/kernel/init_task.c index ed2f93cf7c66..44b274dff33f 100644 --- a/arch/v850/kernel/init_task.c +++ b/arch/v850/kernel/init_task.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <asm/pgtable.h> | 21 | #include <asm/pgtable.h> |
22 | 22 | ||
23 | static struct fs_struct init_fs = INIT_FS; | 23 | static struct fs_struct init_fs = INIT_FS; |
24 | static struct files_struct init_files = INIT_FILES; | ||
25 | static struct signal_struct init_signals = INIT_SIGNALS (init_signals); | 24 | static struct signal_struct init_signals = INIT_SIGNALS (init_signals); |
26 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 25 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
27 | struct mm_struct init_mm = INIT_MM (init_mm); | 26 | struct mm_struct init_mm = INIT_MM (init_mm); |
diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c index 3d01e47777db..a4f93b4120c1 100644 --- a/arch/x86/kernel/init_task.c +++ b/arch/x86/kernel/init_task.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <asm/desc.h> | 11 | #include <asm/desc.h> |
12 | 12 | ||
13 | static struct fs_struct init_fs = INIT_FS; | 13 | static struct fs_struct init_fs = INIT_FS; |
14 | static struct files_struct init_files = INIT_FILES; | ||
15 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 14 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
16 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 15 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
17 | struct mm_struct init_mm = INIT_MM(init_mm); | 16 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/arch/xtensa/kernel/init_task.c b/arch/xtensa/kernel/init_task.c index 021b4f46ff94..3df469dbe814 100644 --- a/arch/xtensa/kernel/init_task.c +++ b/arch/xtensa/kernel/init_task.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
23 | 23 | ||
24 | static struct fs_struct init_fs = INIT_FS; | 24 | static struct fs_struct init_fs = INIT_FS; |
25 | static struct files_struct init_files = INIT_FILES; | ||
26 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | 25 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
27 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | 26 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
28 | struct mm_struct init_mm = INIT_MM(init_mm); | 27 | struct mm_struct init_mm = INIT_MM(init_mm); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index b25707fee2cc..0fa95b198e6e 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -256,7 +256,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, | |||
256 | return -EFAULT; | 256 | return -EFAULT; |
257 | len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); | 257 | len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); |
258 | if (!len || len > MAX_ARG_STRLEN) | 258 | if (!len || len > MAX_ARG_STRLEN) |
259 | return 0; | 259 | return -EINVAL; |
260 | p += len; | 260 | p += len; |
261 | } | 261 | } |
262 | if (__put_user(0, argv)) | 262 | if (__put_user(0, argv)) |
@@ -268,7 +268,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, | |||
268 | return -EFAULT; | 268 | return -EFAULT; |
269 | len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); | 269 | len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); |
270 | if (!len || len > MAX_ARG_STRLEN) | 270 | if (!len || len > MAX_ARG_STRLEN) |
271 | return 0; | 271 | return -EINVAL; |
272 | p += len; | 272 | p += len; |
273 | } | 273 | } |
274 | if (__put_user(0, envp)) | 274 | if (__put_user(0, envp)) |
@@ -1900,7 +1900,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
1900 | /* alloc memory for large data structures: too large to be on stack */ | 1900 | /* alloc memory for large data structures: too large to be on stack */ |
1901 | elf = kmalloc(sizeof(*elf), GFP_KERNEL); | 1901 | elf = kmalloc(sizeof(*elf), GFP_KERNEL); |
1902 | if (!elf) | 1902 | if (!elf) |
1903 | goto cleanup; | 1903 | goto out; |
1904 | 1904 | ||
1905 | segs = current->mm->map_count; | 1905 | segs = current->mm->map_count; |
1906 | #ifdef ELF_CORE_EXTRA_PHDRS | 1906 | #ifdef ELF_CORE_EXTRA_PHDRS |
@@ -2034,8 +2034,9 @@ end_coredump: | |||
2034 | set_fs(fs); | 2034 | set_fs(fs); |
2035 | 2035 | ||
2036 | cleanup: | 2036 | cleanup: |
2037 | kfree(elf); | ||
2038 | free_note_info(&info); | 2037 | free_note_info(&info); |
2038 | kfree(elf); | ||
2039 | out: | ||
2039 | return has_dumped; | 2040 | return has_dumped; |
2040 | } | 2041 | } |
2041 | 2042 | ||
diff --git a/fs/compat.c b/fs/compat.c index 332a869d2c53..ed43e17a5dc6 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1405,7 +1405,7 @@ int compat_do_execve(char * filename, | |||
1405 | /* execve success */ | 1405 | /* execve success */ |
1406 | security_bprm_free(bprm); | 1406 | security_bprm_free(bprm); |
1407 | acct_update_integrals(current); | 1407 | acct_update_integrals(current); |
1408 | kfree(bprm); | 1408 | free_bprm(bprm); |
1409 | return retval; | 1409 | return retval; |
1410 | } | 1410 | } |
1411 | 1411 | ||
@@ -1424,7 +1424,7 @@ out_file: | |||
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | out_kfree: | 1426 | out_kfree: |
1427 | kfree(bprm); | 1427 | free_bprm(bprm); |
1428 | 1428 | ||
1429 | out_ret: | 1429 | out_ret: |
1430 | return retval; | 1430 | return retval; |
@@ -1251,6 +1251,12 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1251 | 1251 | ||
1252 | EXPORT_SYMBOL(search_binary_handler); | 1252 | EXPORT_SYMBOL(search_binary_handler); |
1253 | 1253 | ||
1254 | void free_bprm(struct linux_binprm *bprm) | ||
1255 | { | ||
1256 | free_arg_pages(bprm); | ||
1257 | kfree(bprm); | ||
1258 | } | ||
1259 | |||
1254 | /* | 1260 | /* |
1255 | * sys_execve() executes a new program. | 1261 | * sys_execve() executes a new program. |
1256 | */ | 1262 | */ |
@@ -1320,17 +1326,15 @@ int do_execve(char * filename, | |||
1320 | retval = search_binary_handler(bprm,regs); | 1326 | retval = search_binary_handler(bprm,regs); |
1321 | if (retval >= 0) { | 1327 | if (retval >= 0) { |
1322 | /* execve success */ | 1328 | /* execve success */ |
1323 | free_arg_pages(bprm); | ||
1324 | security_bprm_free(bprm); | 1329 | security_bprm_free(bprm); |
1325 | acct_update_integrals(current); | 1330 | acct_update_integrals(current); |
1326 | kfree(bprm); | 1331 | free_bprm(bprm); |
1327 | if (displaced) | 1332 | if (displaced) |
1328 | put_files_struct(displaced); | 1333 | put_files_struct(displaced); |
1329 | return retval; | 1334 | return retval; |
1330 | } | 1335 | } |
1331 | 1336 | ||
1332 | out: | 1337 | out: |
1333 | free_arg_pages(bprm); | ||
1334 | if (bprm->security) | 1338 | if (bprm->security) |
1335 | security_bprm_free(bprm); | 1339 | security_bprm_free(bprm); |
1336 | 1340 | ||
@@ -1344,7 +1348,7 @@ out_file: | |||
1344 | fput(bprm->file); | 1348 | fput(bprm->file); |
1345 | } | 1349 | } |
1346 | out_kfree: | 1350 | out_kfree: |
1347 | kfree(bprm); | 1351 | free_bprm(bprm); |
1348 | 1352 | ||
1349 | out_files: | 1353 | out_files: |
1350 | if (displaced) | 1354 | if (displaced) |
@@ -26,6 +26,8 @@ struct fdtable_defer { | |||
26 | }; | 26 | }; |
27 | 27 | ||
28 | int sysctl_nr_open __read_mostly = 1024*1024; | 28 | int sysctl_nr_open __read_mostly = 1024*1024; |
29 | int sysctl_nr_open_min = BITS_PER_LONG; | ||
30 | int sysctl_nr_open_max = 1024 * 1024; /* raised later */ | ||
29 | 31 | ||
30 | /* | 32 | /* |
31 | * We use this list to defer free fdtables that have vmalloced | 33 | * We use this list to defer free fdtables that have vmalloced |
@@ -119,8 +121,6 @@ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt) | |||
119 | unsigned int cpy, set; | 121 | unsigned int cpy, set; |
120 | 122 | ||
121 | BUG_ON(nfdt->max_fds < ofdt->max_fds); | 123 | BUG_ON(nfdt->max_fds < ofdt->max_fds); |
122 | if (ofdt->max_fds == 0) | ||
123 | return; | ||
124 | 124 | ||
125 | cpy = ofdt->max_fds * sizeof(struct file *); | 125 | cpy = ofdt->max_fds * sizeof(struct file *); |
126 | set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *); | 126 | set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *); |
@@ -261,6 +261,139 @@ int expand_files(struct files_struct *files, int nr) | |||
261 | return expand_fdtable(files, nr); | 261 | return expand_fdtable(files, nr); |
262 | } | 262 | } |
263 | 263 | ||
264 | static int count_open_files(struct fdtable *fdt) | ||
265 | { | ||
266 | int size = fdt->max_fds; | ||
267 | int i; | ||
268 | |||
269 | /* Find the last open fd */ | ||
270 | for (i = size/(8*sizeof(long)); i > 0; ) { | ||
271 | if (fdt->open_fds->fds_bits[--i]) | ||
272 | break; | ||
273 | } | ||
274 | i = (i+1) * 8 * sizeof(long); | ||
275 | return i; | ||
276 | } | ||
277 | |||
278 | /* | ||
279 | * Allocate a new files structure and copy contents from the | ||
280 | * passed in files structure. | ||
281 | * errorp will be valid only when the returned files_struct is NULL. | ||
282 | */ | ||
283 | struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) | ||
284 | { | ||
285 | struct files_struct *newf; | ||
286 | struct file **old_fds, **new_fds; | ||
287 | int open_files, size, i; | ||
288 | struct fdtable *old_fdt, *new_fdt; | ||
289 | |||
290 | *errorp = -ENOMEM; | ||
291 | newf = kmem_cache_alloc(files_cachep, GFP_KERNEL); | ||
292 | if (!newf) | ||
293 | goto out; | ||
294 | |||
295 | atomic_set(&newf->count, 1); | ||
296 | |||
297 | spin_lock_init(&newf->file_lock); | ||
298 | newf->next_fd = 0; | ||
299 | new_fdt = &newf->fdtab; | ||
300 | new_fdt->max_fds = NR_OPEN_DEFAULT; | ||
301 | new_fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init; | ||
302 | new_fdt->open_fds = (fd_set *)&newf->open_fds_init; | ||
303 | new_fdt->fd = &newf->fd_array[0]; | ||
304 | INIT_RCU_HEAD(&new_fdt->rcu); | ||
305 | new_fdt->next = NULL; | ||
306 | |||
307 | spin_lock(&oldf->file_lock); | ||
308 | old_fdt = files_fdtable(oldf); | ||
309 | open_files = count_open_files(old_fdt); | ||
310 | |||
311 | /* | ||
312 | * Check whether we need to allocate a larger fd array and fd set. | ||
313 | */ | ||
314 | while (unlikely(open_files > new_fdt->max_fds)) { | ||
315 | spin_unlock(&oldf->file_lock); | ||
316 | |||
317 | if (new_fdt != &newf->fdtab) { | ||
318 | free_fdarr(new_fdt); | ||
319 | free_fdset(new_fdt); | ||
320 | kfree(new_fdt); | ||
321 | } | ||
322 | |||
323 | new_fdt = alloc_fdtable(open_files - 1); | ||
324 | if (!new_fdt) { | ||
325 | *errorp = -ENOMEM; | ||
326 | goto out_release; | ||
327 | } | ||
328 | |||
329 | /* beyond sysctl_nr_open; nothing to do */ | ||
330 | if (unlikely(new_fdt->max_fds < open_files)) { | ||
331 | free_fdarr(new_fdt); | ||
332 | free_fdset(new_fdt); | ||
333 | kfree(new_fdt); | ||
334 | *errorp = -EMFILE; | ||
335 | goto out_release; | ||
336 | } | ||
337 | |||
338 | /* | ||
339 | * Reacquire the oldf lock and a pointer to its fd table | ||
340 | * who knows it may have a new bigger fd table. We need | ||
341 | * the latest pointer. | ||
342 | */ | ||
343 | spin_lock(&oldf->file_lock); | ||
344 | old_fdt = files_fdtable(oldf); | ||
345 | open_files = count_open_files(old_fdt); | ||
346 | } | ||
347 | |||
348 | old_fds = old_fdt->fd; | ||
349 | new_fds = new_fdt->fd; | ||
350 | |||
351 | memcpy(new_fdt->open_fds->fds_bits, | ||
352 | old_fdt->open_fds->fds_bits, open_files/8); | ||
353 | memcpy(new_fdt->close_on_exec->fds_bits, | ||
354 | old_fdt->close_on_exec->fds_bits, open_files/8); | ||
355 | |||
356 | for (i = open_files; i != 0; i--) { | ||
357 | struct file *f = *old_fds++; | ||
358 | if (f) { | ||
359 | get_file(f); | ||
360 | } else { | ||
361 | /* | ||
362 | * The fd may be claimed in the fd bitmap but not yet | ||
363 | * instantiated in the files array if a sibling thread | ||
364 | * is partway through open(). So make sure that this | ||
365 | * fd is available to the new process. | ||
366 | */ | ||
367 | FD_CLR(open_files - i, new_fdt->open_fds); | ||
368 | } | ||
369 | rcu_assign_pointer(*new_fds++, f); | ||
370 | } | ||
371 | spin_unlock(&oldf->file_lock); | ||
372 | |||
373 | /* compute the remainder to be cleared */ | ||
374 | size = (new_fdt->max_fds - open_files) * sizeof(struct file *); | ||
375 | |||
376 | /* This is long word aligned thus could use a optimized version */ | ||
377 | memset(new_fds, 0, size); | ||
378 | |||
379 | if (new_fdt->max_fds > open_files) { | ||
380 | int left = (new_fdt->max_fds-open_files)/8; | ||
381 | int start = open_files / (8 * sizeof(unsigned long)); | ||
382 | |||
383 | memset(&new_fdt->open_fds->fds_bits[start], 0, left); | ||
384 | memset(&new_fdt->close_on_exec->fds_bits[start], 0, left); | ||
385 | } | ||
386 | |||
387 | rcu_assign_pointer(newf->fdt, new_fdt); | ||
388 | |||
389 | return newf; | ||
390 | |||
391 | out_release: | ||
392 | kmem_cache_free(files_cachep, newf); | ||
393 | out: | ||
394 | return NULL; | ||
395 | } | ||
396 | |||
264 | static void __devinit fdtable_defer_list_init(int cpu) | 397 | static void __devinit fdtable_defer_list_init(int cpu) |
265 | { | 398 | { |
266 | struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); | 399 | struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); |
@@ -274,4 +407,19 @@ void __init files_defer_init(void) | |||
274 | int i; | 407 | int i; |
275 | for_each_possible_cpu(i) | 408 | for_each_possible_cpu(i) |
276 | fdtable_defer_list_init(i); | 409 | fdtable_defer_list_init(i); |
410 | sysctl_nr_open_max = min((size_t)INT_MAX, ~(size_t)0/sizeof(void *)) & | ||
411 | -BITS_PER_LONG; | ||
277 | } | 412 | } |
413 | |||
414 | struct files_struct init_files = { | ||
415 | .count = ATOMIC_INIT(1), | ||
416 | .fdt = &init_files.fdtab, | ||
417 | .fdtab = { | ||
418 | .max_fds = NR_OPEN_DEFAULT, | ||
419 | .fd = &init_files.fd_array[0], | ||
420 | .close_on_exec = (fd_set *)&init_files.close_on_exec_init, | ||
421 | .open_fds = (fd_set *)&init_files.open_fds_init, | ||
422 | .rcu = RCU_HEAD_INIT, | ||
423 | }, | ||
424 | .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), | ||
425 | }; | ||
diff --git a/fs/namei.c b/fs/namei.c index 32fd9655485b..c7e43536c49a 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2003,18 +2003,22 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) | |||
2003 | if (IS_ERR(dentry)) | 2003 | if (IS_ERR(dentry)) |
2004 | goto fail; | 2004 | goto fail; |
2005 | 2005 | ||
2006 | if (dentry->d_inode) | ||
2007 | goto eexist; | ||
2006 | /* | 2008 | /* |
2007 | * Special case - lookup gave negative, but... we had foo/bar/ | 2009 | * Special case - lookup gave negative, but... we had foo/bar/ |
2008 | * From the vfs_mknod() POV we just have a negative dentry - | 2010 | * From the vfs_mknod() POV we just have a negative dentry - |
2009 | * all is fine. Let's be bastards - you had / on the end, you've | 2011 | * all is fine. Let's be bastards - you had / on the end, you've |
2010 | * been asking for (non-existent) directory. -ENOENT for you. | 2012 | * been asking for (non-existent) directory. -ENOENT for you. |
2011 | */ | 2013 | */ |
2012 | if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) | 2014 | if (unlikely(!is_dir && nd->last.name[nd->last.len])) { |
2013 | goto enoent; | 2015 | dput(dentry); |
2016 | dentry = ERR_PTR(-ENOENT); | ||
2017 | } | ||
2014 | return dentry; | 2018 | return dentry; |
2015 | enoent: | 2019 | eexist: |
2016 | dput(dentry); | 2020 | dput(dentry); |
2017 | dentry = ERR_PTR(-ENOENT); | 2021 | dentry = ERR_PTR(-EEXIST); |
2018 | fail: | 2022 | fail: |
2019 | return dentry; | 2023 | return dentry; |
2020 | } | 2024 | } |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index b512e48f6d8e..ee0ed48e8348 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -99,6 +99,7 @@ extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); | |||
99 | extern void compute_creds(struct linux_binprm *binprm); | 99 | extern void compute_creds(struct linux_binprm *binprm); |
100 | extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); | 100 | extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); |
101 | extern int set_binfmt(struct linux_binfmt *new); | 101 | extern int set_binfmt(struct linux_binfmt *new); |
102 | extern void free_bprm(struct linux_binprm *); | ||
102 | 103 | ||
103 | #endif /* __KERNEL__ */ | 104 | #endif /* __KERNEL__ */ |
104 | #endif /* _LINUX_BINFMTS_H */ | 105 | #endif /* _LINUX_BINFMTS_H */ |
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index a118f3c0b240..4aab6f12cfab 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h | |||
@@ -93,6 +93,7 @@ struct files_struct *get_files_struct(struct task_struct *); | |||
93 | void put_files_struct(struct files_struct *fs); | 93 | void put_files_struct(struct files_struct *fs); |
94 | void reset_files_struct(struct files_struct *); | 94 | void reset_files_struct(struct files_struct *); |
95 | int unshare_files(struct files_struct **); | 95 | int unshare_files(struct files_struct **); |
96 | struct files_struct *dup_fd(struct files_struct *, int *); | ||
96 | 97 | ||
97 | extern struct kmem_cache *files_cachep; | 98 | extern struct kmem_cache *files_cachep; |
98 | 99 | ||
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index b24c2875aa05..9927a88674a3 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -1,7 +1,6 @@ | |||
1 | #ifndef _LINUX__INIT_TASK_H | 1 | #ifndef _LINUX__INIT_TASK_H |
2 | #define _LINUX__INIT_TASK_H | 2 | #define _LINUX__INIT_TASK_H |
3 | 3 | ||
4 | #include <linux/fdtable.h> | ||
5 | #include <linux/rcupdate.h> | 4 | #include <linux/rcupdate.h> |
6 | #include <linux/irqflags.h> | 5 | #include <linux/irqflags.h> |
7 | #include <linux/utsname.h> | 6 | #include <linux/utsname.h> |
@@ -12,27 +11,7 @@ | |||
12 | #include <linux/securebits.h> | 11 | #include <linux/securebits.h> |
13 | #include <net/net_namespace.h> | 12 | #include <net/net_namespace.h> |
14 | 13 | ||
15 | #define INIT_FDTABLE \ | 14 | extern struct files_struct init_files; |
16 | { \ | ||
17 | .max_fds = NR_OPEN_DEFAULT, \ | ||
18 | .fd = &init_files.fd_array[0], \ | ||
19 | .close_on_exec = (fd_set *)&init_files.close_on_exec_init, \ | ||
20 | .open_fds = (fd_set *)&init_files.open_fds_init, \ | ||
21 | .rcu = RCU_HEAD_INIT, \ | ||
22 | .next = NULL, \ | ||
23 | } | ||
24 | |||
25 | #define INIT_FILES \ | ||
26 | { \ | ||
27 | .count = ATOMIC_INIT(1), \ | ||
28 | .fdt = &init_files.fdtab, \ | ||
29 | .fdtab = INIT_FDTABLE, \ | ||
30 | .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), \ | ||
31 | .next_fd = 0, \ | ||
32 | .close_on_exec_init = { { 0, } }, \ | ||
33 | .open_fds_init = { { 0, } }, \ | ||
34 | .fd_array = { NULL, } \ | ||
35 | } | ||
36 | 15 | ||
37 | #define INIT_KIOCTX(name, which_mm) \ | 16 | #define INIT_KIOCTX(name, which_mm) \ |
38 | { \ | 17 | { \ |
diff --git a/kernel/fork.c b/kernel/fork.c index 933e60ebccae..19908b26cf80 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -660,136 +660,6 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) | |||
660 | return 0; | 660 | return 0; |
661 | } | 661 | } |
662 | 662 | ||
663 | static int count_open_files(struct fdtable *fdt) | ||
664 | { | ||
665 | int size = fdt->max_fds; | ||
666 | int i; | ||
667 | |||
668 | /* Find the last open fd */ | ||
669 | for (i = size/(8*sizeof(long)); i > 0; ) { | ||
670 | if (fdt->open_fds->fds_bits[--i]) | ||
671 | break; | ||
672 | } | ||
673 | i = (i+1) * 8 * sizeof(long); | ||
674 | return i; | ||
675 | } | ||
676 | |||
677 | static struct files_struct *alloc_files(void) | ||
678 | { | ||
679 | struct files_struct *newf; | ||
680 | struct fdtable *fdt; | ||
681 | |||
682 | newf = kmem_cache_alloc(files_cachep, GFP_KERNEL); | ||
683 | if (!newf) | ||
684 | goto out; | ||
685 | |||
686 | atomic_set(&newf->count, 1); | ||
687 | |||
688 | spin_lock_init(&newf->file_lock); | ||
689 | newf->next_fd = 0; | ||
690 | fdt = &newf->fdtab; | ||
691 | fdt->max_fds = NR_OPEN_DEFAULT; | ||
692 | fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init; | ||
693 | fdt->open_fds = (fd_set *)&newf->open_fds_init; | ||
694 | fdt->fd = &newf->fd_array[0]; | ||
695 | INIT_RCU_HEAD(&fdt->rcu); | ||
696 | fdt->next = NULL; | ||
697 | rcu_assign_pointer(newf->fdt, fdt); | ||
698 | out: | ||
699 | return newf; | ||
700 | } | ||
701 | |||
702 | /* | ||
703 | * Allocate a new files structure and copy contents from the | ||
704 | * passed in files structure. | ||
705 | * errorp will be valid only when the returned files_struct is NULL. | ||
706 | */ | ||
707 | static struct files_struct *dup_fd(struct files_struct *oldf, int *errorp) | ||
708 | { | ||
709 | struct files_struct *newf; | ||
710 | struct file **old_fds, **new_fds; | ||
711 | int open_files, size, i; | ||
712 | struct fdtable *old_fdt, *new_fdt; | ||
713 | |||
714 | *errorp = -ENOMEM; | ||
715 | newf = alloc_files(); | ||
716 | if (!newf) | ||
717 | goto out; | ||
718 | |||
719 | spin_lock(&oldf->file_lock); | ||
720 | old_fdt = files_fdtable(oldf); | ||
721 | new_fdt = files_fdtable(newf); | ||
722 | open_files = count_open_files(old_fdt); | ||
723 | |||
724 | /* | ||
725 | * Check whether we need to allocate a larger fd array and fd set. | ||
726 | * Note: we're not a clone task, so the open count won't change. | ||
727 | */ | ||
728 | if (open_files > new_fdt->max_fds) { | ||
729 | new_fdt->max_fds = 0; | ||
730 | spin_unlock(&oldf->file_lock); | ||
731 | spin_lock(&newf->file_lock); | ||
732 | *errorp = expand_files(newf, open_files-1); | ||
733 | spin_unlock(&newf->file_lock); | ||
734 | if (*errorp < 0) | ||
735 | goto out_release; | ||
736 | new_fdt = files_fdtable(newf); | ||
737 | /* | ||
738 | * Reacquire the oldf lock and a pointer to its fd table | ||
739 | * who knows it may have a new bigger fd table. We need | ||
740 | * the latest pointer. | ||
741 | */ | ||
742 | spin_lock(&oldf->file_lock); | ||
743 | old_fdt = files_fdtable(oldf); | ||
744 | } | ||
745 | |||
746 | old_fds = old_fdt->fd; | ||
747 | new_fds = new_fdt->fd; | ||
748 | |||
749 | memcpy(new_fdt->open_fds->fds_bits, | ||
750 | old_fdt->open_fds->fds_bits, open_files/8); | ||
751 | memcpy(new_fdt->close_on_exec->fds_bits, | ||
752 | old_fdt->close_on_exec->fds_bits, open_files/8); | ||
753 | |||
754 | for (i = open_files; i != 0; i--) { | ||
755 | struct file *f = *old_fds++; | ||
756 | if (f) { | ||
757 | get_file(f); | ||
758 | } else { | ||
759 | /* | ||
760 | * The fd may be claimed in the fd bitmap but not yet | ||
761 | * instantiated in the files array if a sibling thread | ||
762 | * is partway through open(). So make sure that this | ||
763 | * fd is available to the new process. | ||
764 | */ | ||
765 | FD_CLR(open_files - i, new_fdt->open_fds); | ||
766 | } | ||
767 | rcu_assign_pointer(*new_fds++, f); | ||
768 | } | ||
769 | spin_unlock(&oldf->file_lock); | ||
770 | |||
771 | /* compute the remainder to be cleared */ | ||
772 | size = (new_fdt->max_fds - open_files) * sizeof(struct file *); | ||
773 | |||
774 | /* This is long word aligned thus could use a optimized version */ | ||
775 | memset(new_fds, 0, size); | ||
776 | |||
777 | if (new_fdt->max_fds > open_files) { | ||
778 | int left = (new_fdt->max_fds-open_files)/8; | ||
779 | int start = open_files / (8 * sizeof(unsigned long)); | ||
780 | |||
781 | memset(&new_fdt->open_fds->fds_bits[start], 0, left); | ||
782 | memset(&new_fdt->close_on_exec->fds_bits[start], 0, left); | ||
783 | } | ||
784 | |||
785 | return newf; | ||
786 | |||
787 | out_release: | ||
788 | kmem_cache_free(files_cachep, newf); | ||
789 | out: | ||
790 | return NULL; | ||
791 | } | ||
792 | |||
793 | static int copy_files(unsigned long clone_flags, struct task_struct * tsk) | 663 | static int copy_files(unsigned long clone_flags, struct task_struct * tsk) |
794 | { | 664 | { |
795 | struct files_struct *oldf, *newf; | 665 | struct files_struct *oldf, *newf; |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d7ffdc59816a..29116652dca8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -81,6 +81,7 @@ extern int compat_log; | |||
81 | extern int maps_protect; | 81 | extern int maps_protect; |
82 | extern int sysctl_stat_interval; | 82 | extern int sysctl_stat_interval; |
83 | extern int latencytop_enabled; | 83 | extern int latencytop_enabled; |
84 | extern int sysctl_nr_open_min, sysctl_nr_open_max; | ||
84 | 85 | ||
85 | /* Constants used for minimum and maximum */ | 86 | /* Constants used for minimum and maximum */ |
86 | #if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM) | 87 | #if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM) |
@@ -1190,7 +1191,9 @@ static struct ctl_table fs_table[] = { | |||
1190 | .data = &sysctl_nr_open, | 1191 | .data = &sysctl_nr_open, |
1191 | .maxlen = sizeof(int), | 1192 | .maxlen = sizeof(int), |
1192 | .mode = 0644, | 1193 | .mode = 0644, |
1193 | .proc_handler = &proc_dointvec, | 1194 | .proc_handler = &proc_dointvec_minmax, |
1195 | .extra1 = &sysctl_nr_open_min, | ||
1196 | .extra2 = &sysctl_nr_open_max, | ||
1194 | }, | 1197 | }, |
1195 | { | 1198 | { |
1196 | .ctl_name = FS_DENTRY, | 1199 | .ctl_name = FS_DENTRY, |