diff options
author | Alex Kelly <alex.page.kelly@gmail.com> | 2012-10-04 20:15:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 14:05:15 -0400 |
commit | 046d662f481830e652ac34cd112249adde16452a (patch) | |
tree | ad13e968b4b02f9e2c35ce45f358477474df80d7 /fs/binfmt_aout.c | |
parent | db9aeca97a58563e1ab927d157c9b5048f233e73 (diff) |
coredump: make core dump functionality optional
Adds an expert Kconfig option, CONFIG_COREDUMP, which allows disabling of
core dump. This saves approximately 2.6k in the compiled kernel, and
complements CONFIG_ELF_CORE, which now depends on it.
CONFIG_COREDUMP also disables coredump-related sysctls, except for
suid_dumpable and related functions, which are necessary for ptrace.
[akpm@linux-foundation.org: fix binfmt_aout.c build]
Signed-off-by: Alex Kelly <alex.page.kelly@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/binfmt_aout.c')
-rw-r--r-- | fs/binfmt_aout.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index d146e181d10d..4b5b5117f00a 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -32,31 +32,8 @@ | |||
32 | 32 | ||
33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); | 33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); |
34 | static int load_aout_library(struct file*); | 34 | static int load_aout_library(struct file*); |
35 | static int aout_core_dump(struct coredump_params *cprm); | ||
36 | |||
37 | static struct linux_binfmt aout_format = { | ||
38 | .module = THIS_MODULE, | ||
39 | .load_binary = load_aout_binary, | ||
40 | .load_shlib = load_aout_library, | ||
41 | .core_dump = aout_core_dump, | ||
42 | .min_coredump = PAGE_SIZE | ||
43 | }; | ||
44 | |||
45 | #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE) | ||
46 | |||
47 | static int set_brk(unsigned long start, unsigned long end) | ||
48 | { | ||
49 | start = PAGE_ALIGN(start); | ||
50 | end = PAGE_ALIGN(end); | ||
51 | if (end > start) { | ||
52 | unsigned long addr; | ||
53 | addr = vm_brk(start, end - start); | ||
54 | if (BAD_ADDR(addr)) | ||
55 | return addr; | ||
56 | } | ||
57 | return 0; | ||
58 | } | ||
59 | 35 | ||
36 | #ifdef CONFIG_COREDUMP | ||
60 | /* | 37 | /* |
61 | * Routine writes a core dump image in the current directory. | 38 | * Routine writes a core dump image in the current directory. |
62 | * Currently only a stub-function. | 39 | * Currently only a stub-function. |
@@ -66,7 +43,6 @@ static int set_brk(unsigned long start, unsigned long end) | |||
66 | * field, which also makes sure the core-dumps won't be recursive if the | 43 | * field, which also makes sure the core-dumps won't be recursive if the |
67 | * dumping of the process results in another error.. | 44 | * dumping of the process results in another error.. |
68 | */ | 45 | */ |
69 | |||
70 | static int aout_core_dump(struct coredump_params *cprm) | 46 | static int aout_core_dump(struct coredump_params *cprm) |
71 | { | 47 | { |
72 | struct file *file = cprm->file; | 48 | struct file *file = cprm->file; |
@@ -135,6 +111,32 @@ end_coredump: | |||
135 | set_fs(fs); | 111 | set_fs(fs); |
136 | return has_dumped; | 112 | return has_dumped; |
137 | } | 113 | } |
114 | #else | ||
115 | #define aout_core_dump NULL | ||
116 | #endif | ||
117 | |||
118 | static struct linux_binfmt aout_format = { | ||
119 | .module = THIS_MODULE, | ||
120 | .load_binary = load_aout_binary, | ||
121 | .load_shlib = load_aout_library, | ||
122 | .core_dump = aout_core_dump, | ||
123 | .min_coredump = PAGE_SIZE | ||
124 | }; | ||
125 | |||
126 | #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE) | ||
127 | |||
128 | static int set_brk(unsigned long start, unsigned long end) | ||
129 | { | ||
130 | start = PAGE_ALIGN(start); | ||
131 | end = PAGE_ALIGN(end); | ||
132 | if (end > start) { | ||
133 | unsigned long addr; | ||
134 | addr = vm_brk(start, end - start); | ||
135 | if (BAD_ADDR(addr)) | ||
136 | return addr; | ||
137 | } | ||
138 | return 0; | ||
139 | } | ||
138 | 140 | ||
139 | /* | 141 | /* |
140 | * create_aout_tables() parses the env- and arg-strings in new user | 142 | * create_aout_tables() parses the env- and arg-strings in new user |