.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/fs/binfmt_aout.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
29 | 30 | |
---|
30 | 31 | #include <linux/uaccess.h> |
---|
31 | 32 | #include <asm/cacheflush.h> |
---|
32 | | -#include <asm/a.out-core.h> |
---|
33 | 33 | |
---|
34 | 34 | static int load_aout_binary(struct linux_binprm *); |
---|
35 | 35 | static int load_aout_library(struct file*); |
---|
36 | | - |
---|
37 | | -#ifdef CONFIG_COREDUMP |
---|
38 | | -/* |
---|
39 | | - * Routine writes a core dump image in the current directory. |
---|
40 | | - * Currently only a stub-function. |
---|
41 | | - * |
---|
42 | | - * Note that setuid/setgid files won't make a core-dump if the uid/gid |
---|
43 | | - * changed due to the set[u|g]id. It's enforced by the "current->mm->dumpable" |
---|
44 | | - * field, which also makes sure the core-dumps won't be recursive if the |
---|
45 | | - * dumping of the process results in another error.. |
---|
46 | | - */ |
---|
47 | | -static int aout_core_dump(struct coredump_params *cprm) |
---|
48 | | -{ |
---|
49 | | - mm_segment_t fs; |
---|
50 | | - int has_dumped = 0; |
---|
51 | | - void __user *dump_start; |
---|
52 | | - int dump_size; |
---|
53 | | - struct user dump; |
---|
54 | | -#ifdef __alpha__ |
---|
55 | | -# define START_DATA(u) ((void __user *)u.start_data) |
---|
56 | | -#else |
---|
57 | | -# define START_DATA(u) ((void __user *)((u.u_tsize << PAGE_SHIFT) + \ |
---|
58 | | - u.start_code)) |
---|
59 | | -#endif |
---|
60 | | -# define START_STACK(u) ((void __user *)u.start_stack) |
---|
61 | | - |
---|
62 | | - fs = get_fs(); |
---|
63 | | - set_fs(KERNEL_DS); |
---|
64 | | - has_dumped = 1; |
---|
65 | | - strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); |
---|
66 | | - dump.u_ar0 = offsetof(struct user, regs); |
---|
67 | | - dump.signal = cprm->siginfo->si_signo; |
---|
68 | | - aout_dump_thread(cprm->regs, &dump); |
---|
69 | | - |
---|
70 | | -/* If the size of the dump file exceeds the rlimit, then see what would happen |
---|
71 | | - if we wrote the stack, but not the data area. */ |
---|
72 | | - if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit) |
---|
73 | | - dump.u_dsize = 0; |
---|
74 | | - |
---|
75 | | -/* Make sure we have enough room to write the stack and data areas. */ |
---|
76 | | - if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit) |
---|
77 | | - dump.u_ssize = 0; |
---|
78 | | - |
---|
79 | | -/* make sure we actually have a data and stack area to dump */ |
---|
80 | | - set_fs(USER_DS); |
---|
81 | | - if (!access_ok(VERIFY_READ, START_DATA(dump), dump.u_dsize << PAGE_SHIFT)) |
---|
82 | | - dump.u_dsize = 0; |
---|
83 | | - if (!access_ok(VERIFY_READ, START_STACK(dump), dump.u_ssize << PAGE_SHIFT)) |
---|
84 | | - dump.u_ssize = 0; |
---|
85 | | - |
---|
86 | | - set_fs(KERNEL_DS); |
---|
87 | | -/* struct user */ |
---|
88 | | - if (!dump_emit(cprm, &dump, sizeof(dump))) |
---|
89 | | - goto end_coredump; |
---|
90 | | -/* Now dump all of the user data. Include malloced stuff as well */ |
---|
91 | | - if (!dump_skip(cprm, PAGE_SIZE - sizeof(dump))) |
---|
92 | | - goto end_coredump; |
---|
93 | | -/* now we start writing out the user space info */ |
---|
94 | | - set_fs(USER_DS); |
---|
95 | | -/* Dump the data area */ |
---|
96 | | - if (dump.u_dsize != 0) { |
---|
97 | | - dump_start = START_DATA(dump); |
---|
98 | | - dump_size = dump.u_dsize << PAGE_SHIFT; |
---|
99 | | - if (!dump_emit(cprm, dump_start, dump_size)) |
---|
100 | | - goto end_coredump; |
---|
101 | | - } |
---|
102 | | -/* Now prepare to dump the stack area */ |
---|
103 | | - if (dump.u_ssize != 0) { |
---|
104 | | - dump_start = START_STACK(dump); |
---|
105 | | - dump_size = dump.u_ssize << PAGE_SHIFT; |
---|
106 | | - if (!dump_emit(cprm, dump_start, dump_size)) |
---|
107 | | - goto end_coredump; |
---|
108 | | - } |
---|
109 | | -end_coredump: |
---|
110 | | - set_fs(fs); |
---|
111 | | - return has_dumped; |
---|
112 | | -} |
---|
113 | | -#else |
---|
114 | | -#define aout_core_dump NULL |
---|
115 | | -#endif |
---|
116 | 36 | |
---|
117 | 37 | static struct linux_binfmt aout_format = { |
---|
118 | 38 | .module = THIS_MODULE, |
---|
119 | 39 | .load_binary = load_aout_binary, |
---|
120 | 40 | .load_shlib = load_aout_library, |
---|
121 | | - .core_dump = aout_core_dump, |
---|
122 | | - .min_coredump = PAGE_SIZE |
---|
123 | 41 | }; |
---|
124 | 42 | |
---|
125 | 43 | #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE) |
---|
.. | .. |
---|
233 | 151 | return -ENOMEM; |
---|
234 | 152 | |
---|
235 | 153 | /* Flush all traces of the currently running executable */ |
---|
236 | | - retval = flush_old_exec(bprm); |
---|
| 154 | + retval = begin_new_exec(bprm); |
---|
237 | 155 | if (retval) |
---|
238 | 156 | return retval; |
---|
239 | 157 | |
---|
.. | .. |
---|
256 | 174 | if (retval < 0) |
---|
257 | 175 | return retval; |
---|
258 | 176 | |
---|
259 | | - install_exec_creds(bprm); |
---|
260 | 177 | |
---|
261 | 178 | if (N_MAGIC(ex) == OMAGIC) { |
---|
262 | 179 | unsigned long text_addr, map_size; |
---|