hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/ia32/ia32_aout.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * a.out loader for x86-64
34 *
....@@ -29,7 +30,6 @@
2930 #include <linux/sched/task_stack.h>
3031
3132 #include <linux/uaccess.h>
32
-#include <asm/pgalloc.h>
3333 #include <asm/cacheflush.h>
3434 #include <asm/user32.h>
3535 #include <asm/ia32.h>
....@@ -39,82 +39,10 @@
3939 static int load_aout_binary(struct linux_binprm *);
4040 static int load_aout_library(struct file *);
4141
42
-#ifdef CONFIG_COREDUMP
43
-static int aout_core_dump(struct coredump_params *);
44
-
45
-static 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
- */
54
-static 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
-
11042 static struct linux_binfmt aout_format = {
11143 .module = THIS_MODULE,
11244 .load_binary = load_aout_binary,
11345 .load_shlib = load_aout_library,
114
-#ifdef CONFIG_COREDUMP
115
- .core_dump = aout_core_dump,
116
-#endif
117
- .min_coredump = PAGE_SIZE
11846 };
11947
12048 static int set_brk(unsigned long start, unsigned long end)
....@@ -126,93 +54,6 @@
12654 return vm_brk(start, end - start);
12755 }
12856
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
-
150
-static 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(VERIFY_READ, (void *) (unsigned long)START_DATA(dump),
182
- dump.u_dsize << PAGE_SHIFT))
183
- dump.u_dsize = 0;
184
- if (!access_ok(VERIFY_READ, (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
- }
211
-end_coredump:
212
- set_fs(fs);
213
- return has_dumped;
214
-}
215
-#endif
21657
21758 /*
21859 * create_aout_tables() parses the env- and arg-strings in new user
....@@ -289,7 +130,7 @@
289130 return -ENOMEM;
290131
291132 /* Flush all traces of the currently running executable */
292
- retval = flush_old_exec(bprm);
133
+ retval = begin_new_exec(bprm);
293134 if (retval)
294135 return retval;
295136
....@@ -313,8 +154,6 @@
313154 retval = setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
314155 if (retval < 0)
315156 return retval;
316
-
317
- install_exec_creds(bprm);
318157
319158 if (N_MAGIC(ex) == OMAGIC) {
320159 unsigned long text_addr, map_size;
....@@ -400,7 +239,6 @@
400239 (regs)->ss = __USER32_DS;
401240 regs->r8 = regs->r9 = regs->r10 = regs->r11 =
402241 regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
403
- set_fs(USER_DS);
404242 return 0;
405243 }
406244