diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-06 11:10:08 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:22 -0500 |
| commit | 7d2f551f6dc933f87933e906e48583169bbc7c27 (patch) | |
| tree | ee596f27147a2a8e280a95d4b8ba41c5914a0ec8 /arch/x86/ia32 | |
| parent | 0f6ed63b170778b9c93fb0ae4017f110c9ee6416 (diff) | |
restore 32bit aout coredump
just getting rid of bitrot
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/x86/ia32')
| -rw-r--r-- | arch/x86/ia32/ia32_aout.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index bae3aba95b15..80361c00fb64 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/personality.h> | 25 | #include <linux/personality.h> |
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
| 28 | #include <linux/perf_event.h> | ||
| 28 | 29 | ||
| 29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
| 30 | #include <asm/pgalloc.h> | 31 | #include <asm/pgalloc.h> |
| @@ -33,14 +34,18 @@ | |||
| 33 | #include <asm/ia32.h> | 34 | #include <asm/ia32.h> |
| 34 | 35 | ||
| 35 | #undef WARN_OLD | 36 | #undef WARN_OLD |
| 36 | #undef CORE_DUMP /* definitely broken */ | ||
| 37 | 37 | ||
| 38 | static int load_aout_binary(struct linux_binprm *); | 38 | static int load_aout_binary(struct linux_binprm *); |
| 39 | static int load_aout_library(struct file *); | 39 | static int load_aout_library(struct file *); |
| 40 | 40 | ||
| 41 | #ifdef CORE_DUMP | 41 | #ifdef CONFIG_COREDUMP |
| 42 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, | 42 | static int aout_core_dump(struct coredump_params *); |
| 43 | unsigned long limit); | 43 | |
| 44 | static unsigned long get_dr(int n) | ||
| 45 | { | ||
| 46 | struct perf_event *bp = current->thread.ptrace_bps[n]; | ||
| 47 | return bp ? bp->hw.info.address : 0; | ||
| 48 | } | ||
| 44 | 49 | ||
| 45 | /* | 50 | /* |
| 46 | * fill in the user structure for a core dump.. | 51 | * fill in the user structure for a core dump.. |
| @@ -48,6 +53,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, | |||
| 48 | static void dump_thread32(struct pt_regs *regs, struct user32 *dump) | 53 | static void dump_thread32(struct pt_regs *regs, struct user32 *dump) |
| 49 | { | 54 | { |
| 50 | u32 fs, gs; | 55 | u32 fs, gs; |
| 56 | memset(dump, 0, sizeof(*dump)); | ||
| 51 | 57 | ||
| 52 | /* changed the size calculations - should hopefully work better. lbt */ | 58 | /* changed the size calculations - should hopefully work better. lbt */ |
| 53 | dump->magic = CMAGIC; | 59 | dump->magic = CMAGIC; |
| @@ -57,15 +63,12 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump) | |||
| 57 | dump->u_dsize = ((unsigned long) | 63 | dump->u_dsize = ((unsigned long) |
| 58 | (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; | 64 | (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; |
| 59 | dump->u_dsize -= dump->u_tsize; | 65 | dump->u_dsize -= dump->u_tsize; |
| 60 | dump->u_ssize = 0; | 66 | dump->u_debugreg[0] = get_dr(0); |
| 61 | dump->u_debugreg[0] = current->thread.debugreg0; | 67 | dump->u_debugreg[1] = get_dr(1); |
| 62 | dump->u_debugreg[1] = current->thread.debugreg1; | 68 | dump->u_debugreg[2] = get_dr(2); |
| 63 | dump->u_debugreg[2] = current->thread.debugreg2; | 69 | dump->u_debugreg[3] = get_dr(3); |
| 64 | dump->u_debugreg[3] = current->thread.debugreg3; | ||
| 65 | dump->u_debugreg[4] = 0; | ||
| 66 | dump->u_debugreg[5] = 0; | ||
| 67 | dump->u_debugreg[6] = current->thread.debugreg6; | 70 | dump->u_debugreg[6] = current->thread.debugreg6; |
| 68 | dump->u_debugreg[7] = current->thread.debugreg7; | 71 | dump->u_debugreg[7] = current->thread.ptrace_dr7; |
| 69 | 72 | ||
| 70 | if (dump->start_stack < 0xc0000000) { | 73 | if (dump->start_stack < 0xc0000000) { |
| 71 | unsigned long tmp; | 74 | unsigned long tmp; |
| @@ -74,24 +77,24 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump) | |||
| 74 | dump->u_ssize = tmp >> PAGE_SHIFT; | 77 | dump->u_ssize = tmp >> PAGE_SHIFT; |
| 75 | } | 78 | } |
| 76 | 79 | ||
| 77 | dump->regs.bx = regs->bx; | 80 | dump->regs.ebx = regs->bx; |
| 78 | dump->regs.cx = regs->cx; | 81 | dump->regs.ecx = regs->cx; |
| 79 | dump->regs.dx = regs->dx; | 82 | dump->regs.edx = regs->dx; |
| 80 | dump->regs.si = regs->si; | 83 | dump->regs.esi = regs->si; |
| 81 | dump->regs.di = regs->di; | 84 | dump->regs.edi = regs->di; |
| 82 | dump->regs.bp = regs->bp; | 85 | dump->regs.ebp = regs->bp; |
| 83 | dump->regs.ax = regs->ax; | 86 | dump->regs.eax = regs->ax; |
| 84 | dump->regs.ds = current->thread.ds; | 87 | dump->regs.ds = current->thread.ds; |
| 85 | dump->regs.es = current->thread.es; | 88 | dump->regs.es = current->thread.es; |
| 86 | savesegment(fs, fs); | 89 | savesegment(fs, fs); |
| 87 | dump->regs.fs = fs; | 90 | dump->regs.fs = fs; |
| 88 | savesegment(gs, gs); | 91 | savesegment(gs, gs); |
| 89 | dump->regs.gs = gs; | 92 | dump->regs.gs = gs; |
| 90 | dump->regs.orig_ax = regs->orig_ax; | 93 | dump->regs.orig_eax = regs->orig_ax; |
| 91 | dump->regs.ip = regs->ip; | 94 | dump->regs.eip = regs->ip; |
| 92 | dump->regs.cs = regs->cs; | 95 | dump->regs.cs = regs->cs; |
| 93 | dump->regs.flags = regs->flags; | 96 | dump->regs.eflags = regs->flags; |
| 94 | dump->regs.sp = regs->sp; | 97 | dump->regs.esp = regs->sp; |
| 95 | dump->regs.ss = regs->ss; | 98 | dump->regs.ss = regs->ss; |
| 96 | 99 | ||
| 97 | #if 1 /* FIXME */ | 100 | #if 1 /* FIXME */ |
| @@ -107,7 +110,7 @@ static struct linux_binfmt aout_format = { | |||
| 107 | .module = THIS_MODULE, | 110 | .module = THIS_MODULE, |
| 108 | .load_binary = load_aout_binary, | 111 | .load_binary = load_aout_binary, |
| 109 | .load_shlib = load_aout_library, | 112 | .load_shlib = load_aout_library, |
| 110 | #ifdef CORE_DUMP | 113 | #ifdef CONFIG_COREDUMP |
| 111 | .core_dump = aout_core_dump, | 114 | .core_dump = aout_core_dump, |
| 112 | #endif | 115 | #endif |
| 113 | .min_coredump = PAGE_SIZE | 116 | .min_coredump = PAGE_SIZE |
| @@ -122,7 +125,7 @@ static void set_brk(unsigned long start, unsigned long end) | |||
| 122 | vm_brk(start, end - start); | 125 | vm_brk(start, end - start); |
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | #ifdef CORE_DUMP | 128 | #ifdef CONFIG_COREDUMP |
| 126 | /* | 129 | /* |
| 127 | * These are the only things you should do on a core-file: use only these | 130 | * These are the only things you should do on a core-file: use only these |
| 128 | * macros to write out all the necessary info. | 131 | * macros to write out all the necessary info. |
| @@ -131,14 +134,14 @@ static void set_brk(unsigned long start, unsigned long end) | |||
| 131 | #include <linux/coredump.h> | 134 | #include <linux/coredump.h> |
| 132 | 135 | ||
| 133 | #define DUMP_WRITE(addr, nr) \ | 136 | #define DUMP_WRITE(addr, nr) \ |
| 134 | if (!dump_write(file, (void *)(addr), (nr))) \ | 137 | if (!dump_write(cprm->file, (void *)(addr), (nr))) \ |
| 135 | goto end_coredump; | 138 | goto end_coredump; |
| 136 | 139 | ||
| 137 | #define DUMP_SEEK(offset) \ | 140 | #define DUMP_SEEK(offset) \ |
| 138 | if (!dump_seek(file, offset)) \ | 141 | if (!dump_seek(cprm->file, offset)) \ |
| 139 | goto end_coredump; | 142 | goto end_coredump; |
| 140 | 143 | ||
| 141 | #define START_DATA() (u.u_tsize << PAGE_SHIFT) | 144 | #define START_DATA(u) (u.u_tsize << PAGE_SHIFT) |
| 142 | #define START_STACK(u) (u.start_stack) | 145 | #define START_STACK(u) (u.start_stack) |
| 143 | 146 | ||
| 144 | /* | 147 | /* |
| @@ -151,8 +154,7 @@ static void set_brk(unsigned long start, unsigned long end) | |||
| 151 | * dumping of the process results in another error.. | 154 | * dumping of the process results in another error.. |
| 152 | */ | 155 | */ |
| 153 | 156 | ||
| 154 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, | 157 | static int aout_core_dump(struct coredump_params *cprm) |
| 155 | unsigned long limit) | ||
| 156 | { | 158 | { |
| 157 | mm_segment_t fs; | 159 | mm_segment_t fs; |
| 158 | int has_dumped = 0; | 160 | int has_dumped = 0; |
| @@ -164,19 +166,19 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, | |||
| 164 | has_dumped = 1; | 166 | has_dumped = 1; |
| 165 | strncpy(dump.u_comm, current->comm, sizeof(current->comm)); | 167 | strncpy(dump.u_comm, current->comm, sizeof(current->comm)); |
| 166 | dump.u_ar0 = offsetof(struct user32, regs); | 168 | dump.u_ar0 = offsetof(struct user32, regs); |
| 167 | dump.signal = signr; | 169 | dump.signal = cprm->siginfo->si_signo; |
| 168 | dump_thread32(regs, &dump); | 170 | dump_thread32(cprm->regs, &dump); |
| 169 | 171 | ||
| 170 | /* | 172 | /* |
| 171 | * If the size of the dump file exceeds the rlimit, then see | 173 | * If the size of the dump file exceeds the rlimit, then see |
| 172 | * what would happen if we wrote the stack, but not the data | 174 | * what would happen if we wrote the stack, but not the data |
| 173 | * area. | 175 | * area. |
| 174 | */ | 176 | */ |
| 175 | if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > limit) | 177 | if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > cprm->limit) |
| 176 | dump.u_dsize = 0; | 178 | dump.u_dsize = 0; |
| 177 | 179 | ||
| 178 | /* Make sure we have enough room to write the stack and data areas. */ | 180 | /* Make sure we have enough room to write the stack and data areas. */ |
| 179 | if ((dump.u_ssize + 1) * PAGE_SIZE > limit) | 181 | if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit) |
| 180 | dump.u_ssize = 0; | 182 | dump.u_ssize = 0; |
| 181 | 183 | ||
| 182 | /* make sure we actually have a data and stack area to dump */ | 184 | /* make sure we actually have a data and stack area to dump */ |
