hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/fs/binfmt_aout.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/fs/binfmt_aout.c
34 *
....@@ -29,97 +30,14 @@
2930
3031 #include <linux/uaccess.h>
3132 #include <asm/cacheflush.h>
32
-#include <asm/a.out-core.h>
3333
3434 static int load_aout_binary(struct linux_binprm *);
3535 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
11636
11737 static struct linux_binfmt aout_format = {
11838 .module = THIS_MODULE,
11939 .load_binary = load_aout_binary,
12040 .load_shlib = load_aout_library,
121
- .core_dump = aout_core_dump,
122
- .min_coredump = PAGE_SIZE
12341 };
12442
12543 #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
....@@ -233,7 +151,7 @@
233151 return -ENOMEM;
234152
235153 /* Flush all traces of the currently running executable */
236
- retval = flush_old_exec(bprm);
154
+ retval = begin_new_exec(bprm);
237155 if (retval)
238156 return retval;
239157
....@@ -256,7 +174,6 @@
256174 if (retval < 0)
257175 return retval;
258176
259
- install_exec_creds(bprm);
260177
261178 if (N_MAGIC(ex) == OMAGIC) {
262179 unsigned long text_addr, map_size;