summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-05 13:00:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-05 13:00:35 -0500
commit08300f4402abc0eb3bc9c91b27a529836710d32d (patch)
tree86f7df726e9f00c5077db356d5fc6f7617c2924f /arch
parent63bdf4284c38a48af21745ceb148a087b190cd21 (diff)
a.out: remove core dumping support
We're (finally) phasing out a.out support for good. As Borislav Petkov points out, we've supported ELF binaries for about 25 years by now, and coredumping in particular has bitrotted over the years. None of the tool chains even support generating a.out binaries any more, and the plan is to deprecate a.out support entirely for the kernel. But I want to start with just removing the core dumping code, because I can still imagine that somebody actually might want to support a.out as a simpler biinary format. Particularly if you generate some random binaries on the fly, ELF is a much more complicated format (admittedly ELF also does have a lot of toolchain support, mitigating that complexity a lot and you really should have moved over in the last 25 years). So it's at least somewhat possible that somebody out there has some workflow that still involves generating and running a.out executables. In contrast, it's very unlikely that anybody depends on debugging any legacy a.out core files. But regardless, I want this phase-out to be done in two steps, so that we can resurrect a.out support (if needed) without having to resurrect the core file dumping that is almost certainly not needed. Jann Horn pointed to the <asm/a.out-core.h> file that my first trivial cut at this had missed. And Alan Cox points out that the a.out binary loader _could_ be done in user space if somebody wants to, but we might keep just the loader in the kernel if somebody really wants it, since the loader isn't that big and has no really odd special cases like the core dumping does. Acked-by: Borislav Petkov <bp@alien8.de> Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk> Cc: Jann Horn <jannh@google.com> Cc: Richard Weinberger <richard@nod.at> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/include/asm/a.out-core.h81
-rw-r--r--arch/m68k/include/asm/a.out-core.h68
-rw-r--r--arch/um/include/asm/a.out-core.h27
-rw-r--r--arch/x86/ia32/ia32_aout.c159
-rw-r--r--arch/x86/include/asm/a.out-core.h67
5 files changed, 0 insertions, 402 deletions
diff --git a/arch/alpha/include/asm/a.out-core.h b/arch/alpha/include/asm/a.out-core.h
deleted file mode 100644
index 1610d078b064..000000000000
--- a/arch/alpha/include/asm/a.out-core.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.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 Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_A_OUT_CORE_H
13#define _ASM_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16
17#include <linux/user.h>
18#include <linux/mm_types.h>
19
20/*
21 * Fill in the user structure for an ECOFF core dump.
22 */
23static inline void aout_dump_thread(struct pt_regs *pt, struct user *dump)
24{
25 /* switch stack follows right below pt_regs: */
26 struct switch_stack * sw = ((struct switch_stack *) pt) - 1;
27
28 dump->magic = CMAGIC;
29 dump->start_code = current->mm->start_code;
30 dump->start_data = current->mm->start_data;
31 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
32 dump->u_tsize = ((current->mm->end_code - dump->start_code)
33 >> PAGE_SHIFT);
34 dump->u_dsize = ((current->mm->brk + PAGE_SIZE-1 - dump->start_data)
35 >> PAGE_SHIFT);
36 dump->u_ssize = (current->mm->start_stack - dump->start_stack
37 + PAGE_SIZE-1) >> PAGE_SHIFT;
38
39 /*
40 * We store the registers in an order/format that is
41 * compatible with DEC Unix/OSF/1 as this makes life easier
42 * for gdb.
43 */
44 dump->regs[EF_V0] = pt->r0;
45 dump->regs[EF_T0] = pt->r1;
46 dump->regs[EF_T1] = pt->r2;
47 dump->regs[EF_T2] = pt->r3;
48 dump->regs[EF_T3] = pt->r4;
49 dump->regs[EF_T4] = pt->r5;
50 dump->regs[EF_T5] = pt->r6;
51 dump->regs[EF_T6] = pt->r7;
52 dump->regs[EF_T7] = pt->r8;
53 dump->regs[EF_S0] = sw->r9;
54 dump->regs[EF_S1] = sw->r10;
55 dump->regs[EF_S2] = sw->r11;
56 dump->regs[EF_S3] = sw->r12;
57 dump->regs[EF_S4] = sw->r13;
58 dump->regs[EF_S5] = sw->r14;
59 dump->regs[EF_S6] = sw->r15;
60 dump->regs[EF_A3] = pt->r19;
61 dump->regs[EF_A4] = pt->r20;
62 dump->regs[EF_A5] = pt->r21;
63 dump->regs[EF_T8] = pt->r22;
64 dump->regs[EF_T9] = pt->r23;
65 dump->regs[EF_T10] = pt->r24;
66 dump->regs[EF_T11] = pt->r25;
67 dump->regs[EF_RA] = pt->r26;
68 dump->regs[EF_T12] = pt->r27;
69 dump->regs[EF_AT] = pt->r28;
70 dump->regs[EF_SP] = rdusp();
71 dump->regs[EF_PS] = pt->ps;
72 dump->regs[EF_PC] = pt->pc;
73 dump->regs[EF_GP] = pt->gp;
74 dump->regs[EF_A0] = pt->r16;
75 dump->regs[EF_A1] = pt->r17;
76 dump->regs[EF_A2] = pt->r18;
77 memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8);
78}
79
80#endif /* __KERNEL__ */
81#endif /* _ASM_A_OUT_CORE_H */
diff --git a/arch/m68k/include/asm/a.out-core.h b/arch/m68k/include/asm/a.out-core.h
deleted file mode 100644
index ae91ea6bb303..000000000000
--- a/arch/m68k/include/asm/a.out-core.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.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 Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_A_OUT_CORE_H
13#define _ASM_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16
17#include <linux/user.h>
18#include <linux/elfcore.h>
19#include <linux/mm_types.h>
20
21/*
22 * fill in the user structure for an a.out core dump
23 */
24static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
25{
26 struct switch_stack *sw;
27
28/* changed the size calculations - should hopefully work better. lbt */
29 dump->magic = CMAGIC;
30 dump->start_code = 0;
31 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
32 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
33 dump->u_dsize = ((unsigned long) (current->mm->brk +
34 (PAGE_SIZE-1))) >> PAGE_SHIFT;
35 dump->u_dsize -= dump->u_tsize;
36 dump->u_ssize = 0;
37
38 if (dump->start_stack < TASK_SIZE)
39 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
40
41 dump->u_ar0 = offsetof(struct user, regs);
42 sw = ((struct switch_stack *)regs) - 1;
43 dump->regs.d1 = regs->d1;
44 dump->regs.d2 = regs->d2;
45 dump->regs.d3 = regs->d3;
46 dump->regs.d4 = regs->d4;
47 dump->regs.d5 = regs->d5;
48 dump->regs.d6 = sw->d6;
49 dump->regs.d7 = sw->d7;
50 dump->regs.a0 = regs->a0;
51 dump->regs.a1 = regs->a1;
52 dump->regs.a2 = regs->a2;
53 dump->regs.a3 = sw->a3;
54 dump->regs.a4 = sw->a4;
55 dump->regs.a5 = sw->a5;
56 dump->regs.a6 = sw->a6;
57 dump->regs.d0 = regs->d0;
58 dump->regs.orig_d0 = regs->orig_d0;
59 dump->regs.stkadj = regs->stkadj;
60 dump->regs.sr = regs->sr;
61 dump->regs.pc = regs->pc;
62 dump->regs.fmtvec = (regs->format << 12) | regs->vector;
63 /* dump floating point stuff */
64 dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
65}
66
67#endif /* __KERNEL__ */
68#endif /* _ASM_A_OUT_CORE_H */
diff --git a/arch/um/include/asm/a.out-core.h b/arch/um/include/asm/a.out-core.h
deleted file mode 100644
index 995643b18309..000000000000
--- a/arch/um/include/asm/a.out-core.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.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 Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef __UM_A_OUT_CORE_H
13#define __UM_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16
17#include <linux/user.h>
18
19/*
20 * fill in the user structure for an a.out core dump
21 */
22static inline void aout_dump_thread(struct pt_regs *regs, struct user *u)
23{
24}
25
26#endif /* __KERNEL__ */
27#endif /* __UM_A_OUT_CORE_H */
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 7dbbe9ffda17..3c135084e1eb 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -39,82 +39,10 @@
39static int load_aout_binary(struct linux_binprm *); 39static int load_aout_binary(struct linux_binprm *);
40static int load_aout_library(struct file *); 40static int load_aout_library(struct file *);
41 41
42#ifdef CONFIG_COREDUMP
43static int aout_core_dump(struct coredump_params *);
44
45static unsigned long get_dr(int n)
46{
47 struct perf_event *bp = current->thread.ptrace_bps[n];
48 return bp ? bp->hw.info.address : 0;
49}
50
51/*
52 * fill in the user structure for a core dump..
53 */
54static void fill_dump(struct pt_regs *regs, struct user32 *dump)
55{
56 u32 fs, gs;
57 memset(dump, 0, sizeof(*dump));
58
59/* changed the size calculations - should hopefully work better. lbt */
60 dump->magic = CMAGIC;
61 dump->start_code = 0;
62 dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
63 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
64 dump->u_dsize = ((unsigned long)
65 (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
66 dump->u_dsize -= dump->u_tsize;
67 dump->u_debugreg[0] = get_dr(0);
68 dump->u_debugreg[1] = get_dr(1);
69 dump->u_debugreg[2] = get_dr(2);
70 dump->u_debugreg[3] = get_dr(3);
71 dump->u_debugreg[6] = current->thread.debugreg6;
72 dump->u_debugreg[7] = current->thread.ptrace_dr7;
73
74 if (dump->start_stack < 0xc0000000) {
75 unsigned long tmp;
76
77 tmp = (unsigned long) (0xc0000000 - dump->start_stack);
78 dump->u_ssize = tmp >> PAGE_SHIFT;
79 }
80
81 dump->regs.ebx = regs->bx;
82 dump->regs.ecx = regs->cx;
83 dump->regs.edx = regs->dx;
84 dump->regs.esi = regs->si;
85 dump->regs.edi = regs->di;
86 dump->regs.ebp = regs->bp;
87 dump->regs.eax = regs->ax;
88 dump->regs.ds = current->thread.ds;
89 dump->regs.es = current->thread.es;
90 savesegment(fs, fs);
91 dump->regs.fs = fs;
92 savesegment(gs, gs);
93 dump->regs.gs = gs;
94 dump->regs.orig_eax = regs->orig_ax;
95 dump->regs.eip = regs->ip;
96 dump->regs.cs = regs->cs;
97 dump->regs.eflags = regs->flags;
98 dump->regs.esp = regs->sp;
99 dump->regs.ss = regs->ss;
100
101#if 1 /* FIXME */
102 dump->u_fpvalid = 0;
103#else
104 dump->u_fpvalid = dump_fpu(regs, &dump->i387);
105#endif
106}
107
108#endif
109
110static struct linux_binfmt aout_format = { 42static struct linux_binfmt aout_format = {
111 .module = THIS_MODULE, 43 .module = THIS_MODULE,
112 .load_binary = load_aout_binary, 44 .load_binary = load_aout_binary,
113 .load_shlib = load_aout_library, 45 .load_shlib = load_aout_library,
114#ifdef CONFIG_COREDUMP
115 .core_dump = aout_core_dump,
116#endif
117 .min_coredump = PAGE_SIZE
118}; 46};
119 47
120static int set_brk(unsigned long start, unsigned long end) 48static int set_brk(unsigned long start, unsigned long end)
@@ -126,93 +54,6 @@ static int set_brk(unsigned long start, unsigned long end)
126 return vm_brk(start, end - start); 54 return vm_brk(start, end - start);
127} 55}
128 56
129#ifdef CONFIG_COREDUMP
130/*
131 * These are the only things you should do on a core-file: use only these
132 * macros to write out all the necessary info.
133 */
134
135#include <linux/coredump.h>
136
137#define START_DATA(u) (u.u_tsize << PAGE_SHIFT)
138#define START_STACK(u) (u.start_stack)
139
140/*
141 * Routine writes a core dump image in the current directory.
142 * Currently only a stub-function.
143 *
144 * Note that setuid/setgid files won't make a core-dump if the uid/gid
145 * changed due to the set[u|g]id. It's enforced by the "current->mm->dumpable"
146 * field, which also makes sure the core-dumps won't be recursive if the
147 * dumping of the process results in another error..
148 */
149
150static int aout_core_dump(struct coredump_params *cprm)
151{
152 mm_segment_t fs;
153 int has_dumped = 0;
154 unsigned long dump_start, dump_size;
155 struct user32 dump;
156
157 fs = get_fs();
158 set_fs(KERNEL_DS);
159 has_dumped = 1;
160
161 fill_dump(cprm->regs, &dump);
162
163 strncpy(dump.u_comm, current->comm, sizeof(current->comm));
164 dump.u_ar0 = offsetof(struct user32, regs);
165 dump.signal = cprm->siginfo->si_signo;
166
167 /*
168 * If the size of the dump file exceeds the rlimit, then see
169 * what would happen if we wrote the stack, but not the data
170 * area.
171 */
172 if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
173 dump.u_dsize = 0;
174
175 /* Make sure we have enough room to write the stack and data areas. */
176 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
177 dump.u_ssize = 0;
178
179 /* make sure we actually have a data and stack area to dump */
180 set_fs(USER_DS);
181 if (!access_ok((void *) (unsigned long)START_DATA(dump),
182 dump.u_dsize << PAGE_SHIFT))
183 dump.u_dsize = 0;
184 if (!access_ok((void *) (unsigned long)START_STACK(dump),
185 dump.u_ssize << PAGE_SHIFT))
186 dump.u_ssize = 0;
187
188 set_fs(KERNEL_DS);
189 /* struct user */
190 if (!dump_emit(cprm, &dump, sizeof(dump)))
191 goto end_coredump;
192 /* Now dump all of the user data. Include malloced stuff as well */
193 if (!dump_skip(cprm, PAGE_SIZE - sizeof(dump)))
194 goto end_coredump;
195 /* now we start writing out the user space info */
196 set_fs(USER_DS);
197 /* Dump the data area */
198 if (dump.u_dsize != 0) {
199 dump_start = START_DATA(dump);
200 dump_size = dump.u_dsize << PAGE_SHIFT;
201 if (!dump_emit(cprm, (void *)dump_start, dump_size))
202 goto end_coredump;
203 }
204 /* Now prepare to dump the stack area */
205 if (dump.u_ssize != 0) {
206 dump_start = START_STACK(dump);
207 dump_size = dump.u_ssize << PAGE_SHIFT;
208 if (!dump_emit(cprm, (void *)dump_start, dump_size))
209 goto end_coredump;
210 }
211end_coredump:
212 set_fs(fs);
213 return has_dumped;
214}
215#endif
216 57
217/* 58/*
218 * create_aout_tables() parses the env- and arg-strings in new user 59 * create_aout_tables() parses the env- and arg-strings in new user
diff --git a/arch/x86/include/asm/a.out-core.h b/arch/x86/include/asm/a.out-core.h
deleted file mode 100644
index 7d3ece8bfb61..000000000000
--- a/arch/x86/include/asm/a.out-core.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.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 Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_X86_A_OUT_CORE_H
13#define _ASM_X86_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16#ifdef CONFIG_X86_32
17
18#include <linux/user.h>
19#include <linux/elfcore.h>
20#include <linux/mm_types.h>
21
22#include <asm/debugreg.h>
23
24/*
25 * fill in the user structure for an a.out core dump
26 */
27static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
28{
29/* changed the size calculations - should hopefully work better. lbt */
30 dump->magic = CMAGIC;
31 dump->start_code = 0;
32 dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
33 dump->u_tsize = ((unsigned long)current->mm->end_code) >> PAGE_SHIFT;
34 dump->u_dsize = ((unsigned long)(current->mm->brk + (PAGE_SIZE - 1)))
35 >> PAGE_SHIFT;
36 dump->u_dsize -= dump->u_tsize;
37 dump->u_ssize = 0;
38 aout_dump_debugregs(dump);
39
40 if (dump->start_stack < TASK_SIZE)
41 dump->u_ssize = ((unsigned long)(TASK_SIZE - dump->start_stack))
42 >> PAGE_SHIFT;
43
44 dump->regs.bx = regs->bx;
45 dump->regs.cx = regs->cx;
46 dump->regs.dx = regs->dx;
47 dump->regs.si = regs->si;
48 dump->regs.di = regs->di;
49 dump->regs.bp = regs->bp;
50 dump->regs.ax = regs->ax;
51 dump->regs.ds = (u16)regs->ds;
52 dump->regs.es = (u16)regs->es;
53 dump->regs.fs = (u16)regs->fs;
54 dump->regs.gs = get_user_gs(regs);
55 dump->regs.orig_ax = regs->orig_ax;
56 dump->regs.ip = regs->ip;
57 dump->regs.cs = (u16)regs->cs;
58 dump->regs.flags = regs->flags;
59 dump->regs.sp = regs->sp;
60 dump->regs.ss = (u16)regs->ss;
61
62 dump->u_fpvalid = dump_fpu(regs, &dump->i387);
63}
64
65#endif /* CONFIG_X86_32 */
66#endif /* __KERNEL__ */
67#endif /* _ASM_X86_A_OUT_CORE_H */