1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* binfmt_elf_fdpic.c: FDPIC ELF binary format 1 /* binfmt_elf_fdpic.c: FDPIC ELF binary format 3 * 2 * 4 * Copyright (C) 2003, 2004, 2006 Red Hat, Inc 3 * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.c 4 * Written by David Howells (dhowells@redhat.com) 6 * Derived from binfmt_elf.c 5 * Derived from binfmt_elf.c >> 6 * >> 7 * This program is free software; you can redistribute it and/or >> 8 * modify it under the terms of the GNU General Public License >> 9 * as published by the Free Software Foundation; either version >> 10 * 2 of the License, or (at your option) any later version. 7 */ 11 */ 8 12 9 #include <linux/module.h> 13 #include <linux/module.h> 10 14 11 #include <linux/fs.h> 15 #include <linux/fs.h> 12 #include <linux/stat.h> 16 #include <linux/stat.h> 13 #include <linux/sched.h> 17 #include <linux/sched.h> 14 #include <linux/sched/coredump.h> 18 #include <linux/sched/coredump.h> 15 #include <linux/sched/task_stack.h> 19 #include <linux/sched/task_stack.h> 16 #include <linux/sched/cputime.h> 20 #include <linux/sched/cputime.h> 17 #include <linux/mm.h> 21 #include <linux/mm.h> 18 #include <linux/mman.h> 22 #include <linux/mman.h> 19 #include <linux/errno.h> 23 #include <linux/errno.h> 20 #include <linux/signal.h> 24 #include <linux/signal.h> 21 #include <linux/binfmts.h> 25 #include <linux/binfmts.h> 22 #include <linux/string.h> 26 #include <linux/string.h> 23 #include <linux/file.h> 27 #include <linux/file.h> 24 #include <linux/fcntl.h> 28 #include <linux/fcntl.h> 25 #include <linux/slab.h> 29 #include <linux/slab.h> 26 #include <linux/pagemap.h> 30 #include <linux/pagemap.h> 27 #include <linux/security.h> 31 #include <linux/security.h> 28 #include <linux/highmem.h> 32 #include <linux/highmem.h> 29 #include <linux/highuid.h> 33 #include <linux/highuid.h> 30 #include <linux/personality.h> 34 #include <linux/personality.h> 31 #include <linux/ptrace.h> 35 #include <linux/ptrace.h> 32 #include <linux/init.h> 36 #include <linux/init.h> 33 #include <linux/elf.h> 37 #include <linux/elf.h> 34 #include <linux/elf-fdpic.h> 38 #include <linux/elf-fdpic.h> 35 #include <linux/elfcore.h> 39 #include <linux/elfcore.h> 36 #include <linux/coredump.h> 40 #include <linux/coredump.h> 37 #include <linux/dax.h> 41 #include <linux/dax.h> 38 #include <linux/regset.h> << 39 42 40 #include <linux/uaccess.h> 43 #include <linux/uaccess.h> 41 #include <asm/param.h> 44 #include <asm/param.h> >> 45 #include <asm/pgalloc.h> 42 46 43 typedef char *elf_caddr_t; 47 typedef char *elf_caddr_t; 44 48 45 #if 0 49 #if 0 46 #define kdebug(fmt, ...) printk("FDPIC "fmt"\n 50 #define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) 47 #else 51 #else 48 #define kdebug(fmt, ...) do {} while(0) 52 #define kdebug(fmt, ...) do {} while(0) 49 #endif 53 #endif 50 54 51 #if 0 55 #if 0 52 #define kdcore(fmt, ...) printk("FDPIC "fmt"\n 56 #define kdcore(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) 53 #else 57 #else 54 #define kdcore(fmt, ...) do {} while(0) 58 #define kdcore(fmt, ...) do {} while(0) 55 #endif 59 #endif 56 60 57 MODULE_LICENSE("GPL"); 61 MODULE_LICENSE("GPL"); 58 62 59 static int load_elf_fdpic_binary(struct linux_ 63 static int load_elf_fdpic_binary(struct linux_binprm *); 60 static int elf_fdpic_fetch_phdrs(struct elf_fd 64 static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *, struct file *); 61 static int elf_fdpic_map_file(struct elf_fdpic 65 static int elf_fdpic_map_file(struct elf_fdpic_params *, struct file *, 62 struct mm_struct 66 struct mm_struct *, const char *); 63 67 64 static int create_elf_fdpic_tables(struct linu 68 static int create_elf_fdpic_tables(struct linux_binprm *, struct mm_struct *, 65 struct elf_ 69 struct elf_fdpic_params *, 66 struct elf_ 70 struct elf_fdpic_params *); 67 71 68 #ifndef CONFIG_MMU 72 #ifndef CONFIG_MMU 69 static int elf_fdpic_map_file_constdisp_on_ucl 73 static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *, 70 74 struct file *, 71 75 struct mm_struct *); 72 #endif 76 #endif 73 77 74 static int elf_fdpic_map_file_by_direct_mmap(s 78 static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, 75 s 79 struct file *, struct mm_struct *); 76 80 77 #ifdef CONFIG_ELF_CORE 81 #ifdef CONFIG_ELF_CORE 78 static int elf_fdpic_core_dump(struct coredump 82 static int elf_fdpic_core_dump(struct coredump_params *cprm); 79 #endif 83 #endif 80 84 81 static struct linux_binfmt elf_fdpic_format = 85 static struct linux_binfmt elf_fdpic_format = { 82 .module = THIS_MODULE, 86 .module = THIS_MODULE, 83 .load_binary = load_elf_fdpic_binar 87 .load_binary = load_elf_fdpic_binary, 84 #ifdef CONFIG_ELF_CORE 88 #ifdef CONFIG_ELF_CORE 85 .core_dump = elf_fdpic_core_dump, 89 .core_dump = elf_fdpic_core_dump, 86 .min_coredump = ELF_EXEC_PAGESIZE, << 87 #endif 90 #endif >> 91 .min_coredump = ELF_EXEC_PAGESIZE, 88 }; 92 }; 89 93 90 static int __init init_elf_fdpic_binfmt(void) 94 static int __init init_elf_fdpic_binfmt(void) 91 { 95 { 92 register_binfmt(&elf_fdpic_format); 96 register_binfmt(&elf_fdpic_format); 93 return 0; 97 return 0; 94 } 98 } 95 99 96 static void __exit exit_elf_fdpic_binfmt(void) 100 static void __exit exit_elf_fdpic_binfmt(void) 97 { 101 { 98 unregister_binfmt(&elf_fdpic_format); 102 unregister_binfmt(&elf_fdpic_format); 99 } 103 } 100 104 101 core_initcall(init_elf_fdpic_binfmt); 105 core_initcall(init_elf_fdpic_binfmt); 102 module_exit(exit_elf_fdpic_binfmt); 106 module_exit(exit_elf_fdpic_binfmt); 103 107 104 static int is_elf(struct elfhdr *hdr, struct f 108 static int is_elf(struct elfhdr *hdr, struct file *file) 105 { 109 { 106 if (memcmp(hdr->e_ident, ELFMAG, SELFM 110 if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0) 107 return 0; 111 return 0; 108 if (hdr->e_type != ET_EXEC && hdr->e_t 112 if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) 109 return 0; 113 return 0; 110 if (!elf_check_arch(hdr)) 114 if (!elf_check_arch(hdr)) 111 return 0; 115 return 0; 112 if (!file->f_op->mmap) 116 if (!file->f_op->mmap) 113 return 0; 117 return 0; 114 return 1; 118 return 1; 115 } 119 } 116 120 117 #ifndef elf_check_fdpic 121 #ifndef elf_check_fdpic 118 #define elf_check_fdpic(x) 0 122 #define elf_check_fdpic(x) 0 119 #endif 123 #endif 120 124 121 #ifndef elf_check_const_displacement 125 #ifndef elf_check_const_displacement 122 #define elf_check_const_displacement(x) 0 126 #define elf_check_const_displacement(x) 0 123 #endif 127 #endif 124 128 125 static int is_constdisp(struct elfhdr *hdr) 129 static int is_constdisp(struct elfhdr *hdr) 126 { 130 { 127 if (!elf_check_fdpic(hdr)) 131 if (!elf_check_fdpic(hdr)) 128 return 1; 132 return 1; 129 if (elf_check_const_displacement(hdr)) 133 if (elf_check_const_displacement(hdr)) 130 return 1; 134 return 1; 131 return 0; 135 return 0; 132 } 136 } 133 137 134 /********************************************* 138 /*****************************************************************************/ 135 /* 139 /* 136 * read the program headers table into memory 140 * read the program headers table into memory 137 */ 141 */ 138 static int elf_fdpic_fetch_phdrs(struct elf_fd 142 static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, 139 struct file * 143 struct file *file) 140 { 144 { 141 struct elf_phdr *phdr; !! 145 struct elf32_phdr *phdr; 142 unsigned long size; 146 unsigned long size; 143 int retval, loop; 147 int retval, loop; 144 loff_t pos = params->hdr.e_phoff; 148 loff_t pos = params->hdr.e_phoff; 145 149 146 if (params->hdr.e_phentsize != sizeof( 150 if (params->hdr.e_phentsize != sizeof(struct elf_phdr)) 147 return -ENOMEM; 151 return -ENOMEM; 148 if (params->hdr.e_phnum > 65536U / siz 152 if (params->hdr.e_phnum > 65536U / sizeof(struct elf_phdr)) 149 return -ENOMEM; 153 return -ENOMEM; 150 154 151 size = params->hdr.e_phnum * sizeof(st 155 size = params->hdr.e_phnum * sizeof(struct elf_phdr); 152 params->phdrs = kmalloc(size, GFP_KERN 156 params->phdrs = kmalloc(size, GFP_KERNEL); 153 if (!params->phdrs) 157 if (!params->phdrs) 154 return -ENOMEM; 158 return -ENOMEM; 155 159 156 retval = kernel_read(file, params->phd 160 retval = kernel_read(file, params->phdrs, size, &pos); 157 if (unlikely(retval != size)) 161 if (unlikely(retval != size)) 158 return retval < 0 ? retval : - 162 return retval < 0 ? retval : -ENOEXEC; 159 163 160 /* determine stack size for this binar 164 /* determine stack size for this binary */ 161 phdr = params->phdrs; 165 phdr = params->phdrs; 162 for (loop = 0; loop < params->hdr.e_ph 166 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 163 if (phdr->p_type != PT_GNU_STA 167 if (phdr->p_type != PT_GNU_STACK) 164 continue; 168 continue; 165 169 166 if (phdr->p_flags & PF_X) 170 if (phdr->p_flags & PF_X) 167 params->flags |= ELF_F 171 params->flags |= ELF_FDPIC_FLAG_EXEC_STACK; 168 else 172 else 169 params->flags |= ELF_F 173 params->flags |= ELF_FDPIC_FLAG_NOEXEC_STACK; 170 174 171 params->stack_size = phdr->p_m 175 params->stack_size = phdr->p_memsz; 172 break; 176 break; 173 } 177 } 174 178 175 return 0; 179 return 0; 176 } 180 } 177 181 178 /********************************************* 182 /*****************************************************************************/ 179 /* 183 /* 180 * load an fdpic binary into various bits of m 184 * load an fdpic binary into various bits of memory 181 */ 185 */ 182 static int load_elf_fdpic_binary(struct linux_ 186 static int load_elf_fdpic_binary(struct linux_binprm *bprm) 183 { 187 { 184 struct elf_fdpic_params exec_params, i 188 struct elf_fdpic_params exec_params, interp_params; 185 struct pt_regs *regs = current_pt_regs 189 struct pt_regs *regs = current_pt_regs(); 186 struct elf_phdr *phdr; 190 struct elf_phdr *phdr; 187 unsigned long stack_size, entryaddr; 191 unsigned long stack_size, entryaddr; 188 #ifdef ELF_FDPIC_PLAT_INIT 192 #ifdef ELF_FDPIC_PLAT_INIT 189 unsigned long dynaddr; 193 unsigned long dynaddr; 190 #endif 194 #endif 191 #ifndef CONFIG_MMU 195 #ifndef CONFIG_MMU 192 unsigned long stack_prot; 196 unsigned long stack_prot; 193 #endif 197 #endif 194 struct file *interpreter = NULL; /* to 198 struct file *interpreter = NULL; /* to shut gcc up */ 195 char *interpreter_name = NULL; 199 char *interpreter_name = NULL; 196 int executable_stack; 200 int executable_stack; 197 int retval, i; 201 int retval, i; 198 loff_t pos; 202 loff_t pos; 199 203 200 kdebug("____ LOAD %d ____", current->p 204 kdebug("____ LOAD %d ____", current->pid); 201 205 202 memset(&exec_params, 0, sizeof(exec_pa 206 memset(&exec_params, 0, sizeof(exec_params)); 203 memset(&interp_params, 0, sizeof(inter 207 memset(&interp_params, 0, sizeof(interp_params)); 204 208 205 exec_params.hdr = *(struct elfhdr *) b 209 exec_params.hdr = *(struct elfhdr *) bprm->buf; 206 exec_params.flags = ELF_FDPIC_FLAG_PRE 210 exec_params.flags = ELF_FDPIC_FLAG_PRESENT | ELF_FDPIC_FLAG_EXECUTABLE; 207 211 208 /* check that this is a binary we know 212 /* check that this is a binary we know how to deal with */ 209 retval = -ENOEXEC; 213 retval = -ENOEXEC; 210 if (!is_elf(&exec_params.hdr, bprm->fi 214 if (!is_elf(&exec_params.hdr, bprm->file)) 211 goto error; 215 goto error; 212 if (!elf_check_fdpic(&exec_params.hdr) 216 if (!elf_check_fdpic(&exec_params.hdr)) { 213 #ifdef CONFIG_MMU 217 #ifdef CONFIG_MMU 214 /* binfmt_elf handles non-fdpi 218 /* binfmt_elf handles non-fdpic elf except on nommu */ 215 goto error; 219 goto error; 216 #else 220 #else 217 /* nommu can only load ET_DYN 221 /* nommu can only load ET_DYN (PIE) ELF */ 218 if (exec_params.hdr.e_type != 222 if (exec_params.hdr.e_type != ET_DYN) 219 goto error; 223 goto error; 220 #endif 224 #endif 221 } 225 } 222 226 223 /* read the program header table */ 227 /* read the program header table */ 224 retval = elf_fdpic_fetch_phdrs(&exec_p 228 retval = elf_fdpic_fetch_phdrs(&exec_params, bprm->file); 225 if (retval < 0) 229 if (retval < 0) 226 goto error; 230 goto error; 227 231 228 /* scan for a program header that spec 232 /* scan for a program header that specifies an interpreter */ 229 phdr = exec_params.phdrs; 233 phdr = exec_params.phdrs; 230 234 231 for (i = 0; i < exec_params.hdr.e_phnu 235 for (i = 0; i < exec_params.hdr.e_phnum; i++, phdr++) { 232 switch (phdr->p_type) { 236 switch (phdr->p_type) { 233 case PT_INTERP: 237 case PT_INTERP: 234 retval = -ENOMEM; 238 retval = -ENOMEM; 235 if (phdr->p_filesz > P 239 if (phdr->p_filesz > PATH_MAX) 236 goto error; 240 goto error; 237 retval = -ENOENT; 241 retval = -ENOENT; 238 if (phdr->p_filesz < 2 242 if (phdr->p_filesz < 2) 239 goto error; 243 goto error; 240 244 241 /* read the name of th 245 /* read the name of the interpreter into memory */ 242 interpreter_name = kma 246 interpreter_name = kmalloc(phdr->p_filesz, GFP_KERNEL); 243 if (!interpreter_name) 247 if (!interpreter_name) 244 goto error; 248 goto error; 245 249 246 pos = phdr->p_offset; 250 pos = phdr->p_offset; 247 retval = kernel_read(b 251 retval = kernel_read(bprm->file, interpreter_name, 248 p 252 phdr->p_filesz, &pos); 249 if (unlikely(retval != 253 if (unlikely(retval != phdr->p_filesz)) { 250 if (retval >= 254 if (retval >= 0) 251 retval 255 retval = -ENOEXEC; 252 goto error; 256 goto error; 253 } 257 } 254 258 255 retval = -ENOENT; 259 retval = -ENOENT; 256 if (interpreter_name[p 260 if (interpreter_name[phdr->p_filesz - 1] != '\0') 257 goto error; 261 goto error; 258 262 259 kdebug("Using ELF inte 263 kdebug("Using ELF interpreter %s", interpreter_name); 260 264 261 /* replace the program 265 /* replace the program with the interpreter */ 262 interpreter = open_exe 266 interpreter = open_exec(interpreter_name); 263 retval = PTR_ERR(inter 267 retval = PTR_ERR(interpreter); 264 if (IS_ERR(interpreter 268 if (IS_ERR(interpreter)) { 265 interpreter = 269 interpreter = NULL; 266 goto error; 270 goto error; 267 } 271 } 268 272 269 /* 273 /* 270 * If the binary is no 274 * If the binary is not readable then enforce 271 * mm->dumpable = 0 re 275 * mm->dumpable = 0 regardless of the interpreter's 272 * permissions. 276 * permissions. 273 */ 277 */ 274 would_dump(bprm, inter 278 would_dump(bprm, interpreter); 275 279 276 pos = 0; 280 pos = 0; 277 retval = kernel_read(i 281 retval = kernel_read(interpreter, bprm->buf, 278 BINPRM 282 BINPRM_BUF_SIZE, &pos); 279 if (unlikely(retval != 283 if (unlikely(retval != BINPRM_BUF_SIZE)) { 280 if (retval >= 284 if (retval >= 0) 281 retval 285 retval = -ENOEXEC; 282 goto error; 286 goto error; 283 } 287 } 284 288 285 interp_params.hdr = *( 289 interp_params.hdr = *((struct elfhdr *) bprm->buf); 286 break; 290 break; 287 291 288 case PT_LOAD: 292 case PT_LOAD: 289 #ifdef CONFIG_MMU 293 #ifdef CONFIG_MMU 290 if (exec_params.load_a 294 if (exec_params.load_addr == 0) 291 exec_params.lo 295 exec_params.load_addr = phdr->p_vaddr; 292 #endif 296 #endif 293 break; 297 break; 294 } 298 } 295 299 296 } 300 } 297 301 298 if (is_constdisp(&exec_params.hdr)) 302 if (is_constdisp(&exec_params.hdr)) 299 exec_params.flags |= ELF_FDPIC 303 exec_params.flags |= ELF_FDPIC_FLAG_CONSTDISP; 300 304 301 /* perform insanity checks on the inte 305 /* perform insanity checks on the interpreter */ 302 if (interpreter_name) { 306 if (interpreter_name) { 303 retval = -ELIBBAD; 307 retval = -ELIBBAD; 304 if (!is_elf(&interp_params.hdr 308 if (!is_elf(&interp_params.hdr, interpreter)) 305 goto error; 309 goto error; 306 310 307 interp_params.flags = ELF_FDPI 311 interp_params.flags = ELF_FDPIC_FLAG_PRESENT; 308 312 309 /* read the interpreter's prog 313 /* read the interpreter's program header table */ 310 retval = elf_fdpic_fetch_phdrs 314 retval = elf_fdpic_fetch_phdrs(&interp_params, interpreter); 311 if (retval < 0) 315 if (retval < 0) 312 goto error; 316 goto error; 313 } 317 } 314 318 315 stack_size = exec_params.stack_size; 319 stack_size = exec_params.stack_size; 316 if (exec_params.flags & ELF_FDPIC_FLAG 320 if (exec_params.flags & ELF_FDPIC_FLAG_EXEC_STACK) 317 executable_stack = EXSTACK_ENA 321 executable_stack = EXSTACK_ENABLE_X; 318 else if (exec_params.flags & ELF_FDPIC 322 else if (exec_params.flags & ELF_FDPIC_FLAG_NOEXEC_STACK) 319 executable_stack = EXSTACK_DIS 323 executable_stack = EXSTACK_DISABLE_X; 320 else 324 else 321 executable_stack = EXSTACK_DEF 325 executable_stack = EXSTACK_DEFAULT; 322 326 323 if (stack_size == 0 && interp_params.f !! 327 if (stack_size == 0) { 324 stack_size = interp_params.sta 328 stack_size = interp_params.stack_size; 325 if (interp_params.flags & ELF_ 329 if (interp_params.flags & ELF_FDPIC_FLAG_EXEC_STACK) 326 executable_stack = EXS 330 executable_stack = EXSTACK_ENABLE_X; 327 else if (interp_params.flags & 331 else if (interp_params.flags & ELF_FDPIC_FLAG_NOEXEC_STACK) 328 executable_stack = EXS 332 executable_stack = EXSTACK_DISABLE_X; 329 else 333 else 330 executable_stack = EXS 334 executable_stack = EXSTACK_DEFAULT; 331 } 335 } 332 336 333 retval = -ENOEXEC; 337 retval = -ENOEXEC; 334 if (stack_size == 0) 338 if (stack_size == 0) 335 stack_size = 131072UL; /* same 339 stack_size = 131072UL; /* same as exec.c's default commit */ 336 340 337 if (is_constdisp(&interp_params.hdr)) 341 if (is_constdisp(&interp_params.hdr)) 338 interp_params.flags |= ELF_FDP 342 interp_params.flags |= ELF_FDPIC_FLAG_CONSTDISP; 339 343 340 /* flush all traces of the currently r 344 /* flush all traces of the currently running executable */ 341 retval = begin_new_exec(bprm); !! 345 retval = flush_old_exec(bprm); 342 if (retval) 346 if (retval) 343 goto error; 347 goto error; 344 348 345 /* there's now no turning back... the 349 /* there's now no turning back... the old userspace image is dead, 346 * defunct, deceased, etc. 350 * defunct, deceased, etc. 347 */ 351 */ 348 SET_PERSONALITY(exec_params.hdr); << 349 if (elf_check_fdpic(&exec_params.hdr)) 352 if (elf_check_fdpic(&exec_params.hdr)) 350 current->personality |= PER_LI !! 353 set_personality(PER_LINUX_FDPIC); >> 354 else >> 355 set_personality(PER_LINUX); 351 if (elf_read_implies_exec(&exec_params 356 if (elf_read_implies_exec(&exec_params.hdr, executable_stack)) 352 current->personality |= READ_I 357 current->personality |= READ_IMPLIES_EXEC; 353 358 354 setup_new_exec(bprm); 359 setup_new_exec(bprm); 355 360 356 set_binfmt(&elf_fdpic_format); 361 set_binfmt(&elf_fdpic_format); 357 362 358 current->mm->start_code = 0; 363 current->mm->start_code = 0; 359 current->mm->end_code = 0; 364 current->mm->end_code = 0; 360 current->mm->start_stack = 0; 365 current->mm->start_stack = 0; 361 current->mm->start_data = 0; 366 current->mm->start_data = 0; 362 current->mm->end_data = 0; 367 current->mm->end_data = 0; 363 current->mm->context.exec_fdpic_loadma 368 current->mm->context.exec_fdpic_loadmap = 0; 364 current->mm->context.interp_fdpic_load 369 current->mm->context.interp_fdpic_loadmap = 0; 365 370 366 #ifdef CONFIG_MMU 371 #ifdef CONFIG_MMU 367 elf_fdpic_arch_lay_out_mm(&exec_params 372 elf_fdpic_arch_lay_out_mm(&exec_params, 368 &interp_para 373 &interp_params, 369 ¤t->mm 374 ¤t->mm->start_stack, 370 ¤t->mm 375 ¤t->mm->start_brk); 371 376 372 retval = setup_arg_pages(bprm, current 377 retval = setup_arg_pages(bprm, current->mm->start_stack, 373 executable_st 378 executable_stack); 374 if (retval < 0) 379 if (retval < 0) 375 goto error; 380 goto error; 376 #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES 381 #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES 377 retval = arch_setup_additional_pages(b 382 retval = arch_setup_additional_pages(bprm, !!interpreter_name); 378 if (retval < 0) 383 if (retval < 0) 379 goto error; 384 goto error; 380 #endif 385 #endif 381 #endif 386 #endif 382 387 383 /* load the executable and interpreter 388 /* load the executable and interpreter into memory */ 384 retval = elf_fdpic_map_file(&exec_para 389 retval = elf_fdpic_map_file(&exec_params, bprm->file, current->mm, 385 "executabl 390 "executable"); 386 if (retval < 0) 391 if (retval < 0) 387 goto error; 392 goto error; 388 393 389 if (interpreter_name) { 394 if (interpreter_name) { 390 retval = elf_fdpic_map_file(&i 395 retval = elf_fdpic_map_file(&interp_params, interpreter, 391 cu 396 current->mm, "interpreter"); 392 if (retval < 0) { 397 if (retval < 0) { 393 printk(KERN_ERR "Unabl 398 printk(KERN_ERR "Unable to load interpreter\n"); 394 goto error; 399 goto error; 395 } 400 } 396 401 >> 402 allow_write_access(interpreter); 397 fput(interpreter); 403 fput(interpreter); 398 interpreter = NULL; 404 interpreter = NULL; 399 } 405 } 400 406 401 #ifdef CONFIG_MMU 407 #ifdef CONFIG_MMU 402 if (!current->mm->start_brk) 408 if (!current->mm->start_brk) 403 current->mm->start_brk = curre 409 current->mm->start_brk = current->mm->end_data; 404 410 405 current->mm->brk = current->mm->start_ 411 current->mm->brk = current->mm->start_brk = 406 PAGE_ALIGN(current->mm->start_ 412 PAGE_ALIGN(current->mm->start_brk); 407 413 408 #else 414 #else 409 /* create a stack area and zero-size b 415 /* create a stack area and zero-size brk area */ 410 stack_size = (stack_size + PAGE_SIZE - 416 stack_size = (stack_size + PAGE_SIZE - 1) & PAGE_MASK; 411 if (stack_size < PAGE_SIZE * 2) 417 if (stack_size < PAGE_SIZE * 2) 412 stack_size = PAGE_SIZE * 2; 418 stack_size = PAGE_SIZE * 2; 413 419 414 stack_prot = PROT_READ | PROT_WRITE; 420 stack_prot = PROT_READ | PROT_WRITE; 415 if (executable_stack == EXSTACK_ENABLE 421 if (executable_stack == EXSTACK_ENABLE_X || 416 (executable_stack == EXSTACK_DEFAU 422 (executable_stack == EXSTACK_DEFAULT && VM_STACK_FLAGS & VM_EXEC)) 417 stack_prot |= PROT_EXEC; 423 stack_prot |= PROT_EXEC; 418 424 419 current->mm->start_brk = vm_mmap(NULL, 425 current->mm->start_brk = vm_mmap(NULL, 0, stack_size, stack_prot, 420 MAP_P 426 MAP_PRIVATE | MAP_ANONYMOUS | 421 MAP_U 427 MAP_UNINITIALIZED | MAP_GROWSDOWN, 422 0); 428 0); 423 429 424 if (IS_ERR_VALUE(current->mm->start_br 430 if (IS_ERR_VALUE(current->mm->start_brk)) { 425 retval = current->mm->start_br 431 retval = current->mm->start_brk; 426 current->mm->start_brk = 0; 432 current->mm->start_brk = 0; 427 goto error; 433 goto error; 428 } 434 } 429 435 430 current->mm->brk = current->mm->start_ 436 current->mm->brk = current->mm->start_brk; 431 current->mm->context.end_brk = current 437 current->mm->context.end_brk = current->mm->start_brk; 432 current->mm->start_stack = current->mm 438 current->mm->start_stack = current->mm->start_brk + stack_size; 433 #endif 439 #endif 434 440 435 retval = create_elf_fdpic_tables(bprm, !! 441 install_exec_creds(bprm); 436 &inte !! 442 if (create_elf_fdpic_tables(bprm, current->mm, 437 if (retval < 0) !! 443 &exec_params, &interp_params) < 0) 438 goto error; 444 goto error; 439 445 440 kdebug("- start_code %lx", current->m 446 kdebug("- start_code %lx", current->mm->start_code); 441 kdebug("- end_code %lx", current->m 447 kdebug("- end_code %lx", current->mm->end_code); 442 kdebug("- start_data %lx", current->m 448 kdebug("- start_data %lx", current->mm->start_data); 443 kdebug("- end_data %lx", current->m 449 kdebug("- end_data %lx", current->mm->end_data); 444 kdebug("- start_brk %lx", current->m 450 kdebug("- start_brk %lx", current->mm->start_brk); 445 kdebug("- brk %lx", current->m 451 kdebug("- brk %lx", current->mm->brk); 446 kdebug("- start_stack %lx", current->m 452 kdebug("- start_stack %lx", current->mm->start_stack); 447 453 448 #ifdef ELF_FDPIC_PLAT_INIT 454 #ifdef ELF_FDPIC_PLAT_INIT 449 /* 455 /* 450 * The ABI may specify that certain re 456 * The ABI may specify that certain registers be set up in special 451 * ways (on i386 %edx is the address o 457 * ways (on i386 %edx is the address of a DT_FINI function, for 452 * example. This macro performs whate 458 * example. This macro performs whatever initialization to 453 * the regs structure is required. 459 * the regs structure is required. 454 */ 460 */ 455 dynaddr = interp_params.dynamic_addr ? 461 dynaddr = interp_params.dynamic_addr ?: exec_params.dynamic_addr; 456 ELF_FDPIC_PLAT_INIT(regs, exec_params. 462 ELF_FDPIC_PLAT_INIT(regs, exec_params.map_addr, interp_params.map_addr, 457 dynaddr); 463 dynaddr); 458 #endif 464 #endif 459 465 460 finalize_exec(bprm); 466 finalize_exec(bprm); 461 /* everything is now ready... get the 467 /* everything is now ready... get the userspace context ready to roll */ 462 entryaddr = interp_params.entry_addr ? 468 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; 463 start_thread(regs, entryaddr, current- 469 start_thread(regs, entryaddr, current->mm->start_stack); 464 470 465 retval = 0; 471 retval = 0; 466 472 467 error: 473 error: 468 if (interpreter) !! 474 if (interpreter) { >> 475 allow_write_access(interpreter); 469 fput(interpreter); 476 fput(interpreter); >> 477 } 470 kfree(interpreter_name); 478 kfree(interpreter_name); 471 kfree(exec_params.phdrs); 479 kfree(exec_params.phdrs); 472 kfree(exec_params.loadmap); 480 kfree(exec_params.loadmap); 473 kfree(interp_params.phdrs); 481 kfree(interp_params.phdrs); 474 kfree(interp_params.loadmap); 482 kfree(interp_params.loadmap); 475 return retval; 483 return retval; 476 } 484 } 477 485 478 /********************************************* 486 /*****************************************************************************/ 479 487 480 #ifndef ELF_BASE_PLATFORM 488 #ifndef ELF_BASE_PLATFORM 481 /* 489 /* 482 * AT_BASE_PLATFORM indicates the "real" hardw 490 * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture. 483 * If the arch defines ELF_BASE_PLATFORM (in a 491 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value 484 * will be copied to the user stack in the sam 492 * will be copied to the user stack in the same manner as AT_PLATFORM. 485 */ 493 */ 486 #define ELF_BASE_PLATFORM NULL 494 #define ELF_BASE_PLATFORM NULL 487 #endif 495 #endif 488 496 489 /* 497 /* 490 * present useful information to the program b 498 * present useful information to the program by shovelling it onto the new 491 * process's stack 499 * process's stack 492 */ 500 */ 493 static int create_elf_fdpic_tables(struct linu 501 static int create_elf_fdpic_tables(struct linux_binprm *bprm, 494 struct mm_s 502 struct mm_struct *mm, 495 struct elf_ 503 struct elf_fdpic_params *exec_params, 496 struct elf_ 504 struct elf_fdpic_params *interp_params) 497 { 505 { 498 const struct cred *cred = current_cred 506 const struct cred *cred = current_cred(); 499 unsigned long sp, csp, nitems; 507 unsigned long sp, csp, nitems; 500 elf_caddr_t __user *argv, *envp; 508 elf_caddr_t __user *argv, *envp; 501 size_t platform_len = 0, len; 509 size_t platform_len = 0, len; 502 char *k_platform, *k_base_platform; 510 char *k_platform, *k_base_platform; 503 char __user *u_platform, *u_base_platf 511 char __user *u_platform, *u_base_platform, *p; 504 int loop; 512 int loop; 505 unsigned long flags = 0; !! 513 int nr; /* reset for each csp adjustment */ 506 int ei_index; << 507 elf_addr_t *elf_info; << 508 514 509 #ifdef CONFIG_MMU 515 #ifdef CONFIG_MMU 510 /* In some cases (e.g. Hyper-Threading 516 /* In some cases (e.g. Hyper-Threading), we want to avoid L1 evictions 511 * by the processes running on the sam 517 * by the processes running on the same package. One thing we can do is 512 * to shuffle the initial stack for th 518 * to shuffle the initial stack for them, so we give the architecture 513 * an opportunity to do so here. 519 * an opportunity to do so here. 514 */ 520 */ 515 sp = arch_align_stack(bprm->p); 521 sp = arch_align_stack(bprm->p); 516 #else 522 #else 517 sp = mm->start_stack; 523 sp = mm->start_stack; 518 524 519 /* stack the program arguments and env 525 /* stack the program arguments and environment */ 520 if (transfer_args_to_stack(bprm, &sp) 526 if (transfer_args_to_stack(bprm, &sp) < 0) 521 return -EFAULT; 527 return -EFAULT; 522 sp &= ~15; 528 sp &= ~15; 523 #endif 529 #endif 524 530 525 /* 531 /* 526 * If this architecture has a platform 532 * If this architecture has a platform capability string, copy it 527 * to userspace. In some cases (Sparc 533 * to userspace. In some cases (Sparc), this info is impossible 528 * for userspace to get any other way, 534 * for userspace to get any other way, in others (i386) it is 529 * merely difficult. 535 * merely difficult. 530 */ 536 */ 531 k_platform = ELF_PLATFORM; 537 k_platform = ELF_PLATFORM; 532 u_platform = NULL; 538 u_platform = NULL; 533 539 534 if (k_platform) { 540 if (k_platform) { 535 platform_len = strlen(k_platfo 541 platform_len = strlen(k_platform) + 1; 536 sp -= platform_len; 542 sp -= platform_len; 537 u_platform = (char __user *) s 543 u_platform = (char __user *) sp; 538 if (copy_to_user(u_platform, k !! 544 if (__copy_to_user(u_platform, k_platform, platform_len) != 0) 539 return -EFAULT; 545 return -EFAULT; 540 } 546 } 541 547 542 /* 548 /* 543 * If this architecture has a "base" p 549 * If this architecture has a "base" platform capability 544 * string, copy it to userspace. 550 * string, copy it to userspace. 545 */ 551 */ 546 k_base_platform = ELF_BASE_PLATFORM; 552 k_base_platform = ELF_BASE_PLATFORM; 547 u_base_platform = NULL; 553 u_base_platform = NULL; 548 554 549 if (k_base_platform) { 555 if (k_base_platform) { 550 platform_len = strlen(k_base_p 556 platform_len = strlen(k_base_platform) + 1; 551 sp -= platform_len; 557 sp -= platform_len; 552 u_base_platform = (char __user 558 u_base_platform = (char __user *) sp; 553 if (copy_to_user(u_base_platfo !! 559 if (__copy_to_user(u_base_platform, k_base_platform, platform_len) != 0) 554 return -EFAULT; 560 return -EFAULT; 555 } 561 } 556 562 557 sp &= ~7UL; 563 sp &= ~7UL; 558 564 559 /* stack the load map(s) */ 565 /* stack the load map(s) */ 560 len = sizeof(struct elf_fdpic_loadmap) !! 566 len = sizeof(struct elf32_fdpic_loadmap); 561 len += sizeof(struct elf_fdpic_loadseg !! 567 len += sizeof(struct elf32_fdpic_loadseg) * exec_params->loadmap->nsegs; 562 sp = (sp - len) & ~7UL; 568 sp = (sp - len) & ~7UL; 563 exec_params->map_addr = sp; 569 exec_params->map_addr = sp; 564 570 565 if (copy_to_user((void __user *) sp, e 571 if (copy_to_user((void __user *) sp, exec_params->loadmap, len) != 0) 566 return -EFAULT; 572 return -EFAULT; 567 573 568 current->mm->context.exec_fdpic_loadma 574 current->mm->context.exec_fdpic_loadmap = (unsigned long) sp; 569 575 570 if (interp_params->loadmap) { 576 if (interp_params->loadmap) { 571 len = sizeof(struct elf_fdpic_ !! 577 len = sizeof(struct elf32_fdpic_loadmap); 572 len += sizeof(struct elf_fdpic !! 578 len += sizeof(struct elf32_fdpic_loadseg) * 573 interp_params->loadmap 579 interp_params->loadmap->nsegs; 574 sp = (sp - len) & ~7UL; 580 sp = (sp - len) & ~7UL; 575 interp_params->map_addr = sp; 581 interp_params->map_addr = sp; 576 582 577 if (copy_to_user((void __user 583 if (copy_to_user((void __user *) sp, interp_params->loadmap, 578 len) != 0) 584 len) != 0) 579 return -EFAULT; 585 return -EFAULT; 580 586 581 current->mm->context.interp_fd 587 current->mm->context.interp_fdpic_loadmap = (unsigned long) sp; 582 } 588 } 583 589 584 /* force 16 byte _final_ alignment her 590 /* force 16 byte _final_ alignment here for generality */ 585 #define DLINFO_ITEMS 15 591 #define DLINFO_ITEMS 15 586 592 587 nitems = 1 + DLINFO_ITEMS + (k_platfor 593 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + 588 (k_base_platform ? 1 : 0) + AT 594 (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH; 589 595 590 if (bprm->have_execfd) !! 596 if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) 591 nitems++; 597 nitems++; 592 #ifdef ELF_HWCAP2 << 593 nitems++; << 594 #endif << 595 598 596 csp = sp; 599 csp = sp; 597 sp -= nitems * 2 * sizeof(unsigned lon 600 sp -= nitems * 2 * sizeof(unsigned long); 598 sp -= (bprm->envc + 1) * sizeof(char * 601 sp -= (bprm->envc + 1) * sizeof(char *); /* envv[] */ 599 sp -= (bprm->argc + 1) * sizeof(char * 602 sp -= (bprm->argc + 1) * sizeof(char *); /* argv[] */ 600 sp -= 1 * sizeof(unsigned long); 603 sp -= 1 * sizeof(unsigned long); /* argc */ 601 604 602 csp -= sp & 15UL; 605 csp -= sp & 15UL; 603 sp -= sp & 15UL; 606 sp -= sp & 15UL; 604 607 605 /* Create the ELF interpreter info */ !! 608 /* put the ELF interpreter info on the stack */ 606 elf_info = (elf_addr_t *)mm->saved_aux !! 609 #define NEW_AUX_ENT(id, val) \ 607 /* update AT_VECTOR_SIZE_BASE if the n !! 610 do { \ 608 #define NEW_AUX_ENT(id, val) \ !! 611 struct { unsigned long _id, _val; } __user *ent; \ 609 do { \ !! 612 \ 610 *elf_info++ = id; \ !! 613 ent = (void __user *) csp; \ 611 *elf_info++ = val; \ !! 614 __put_user((id), &ent[nr]._id); \ >> 615 __put_user((val), &ent[nr]._val); \ >> 616 nr++; \ 612 } while (0) 617 } while (0) 613 618 614 #ifdef ARCH_DLINFO !! 619 nr = 0; 615 /* !! 620 csp -= 2 * sizeof(unsigned long); 616 * ARCH_DLINFO must come first so PPC !! 621 NEW_AUX_ENT(AT_NULL, 0); 617 * AUXV. !! 622 if (k_platform) { 618 * update AT_VECTOR_SIZE_ARCH if the n !! 623 nr = 0; 619 * ARCH_DLINFO changes !! 624 csp -= 2 * sizeof(unsigned long); 620 */ !! 625 NEW_AUX_ENT(AT_PLATFORM, 621 ARCH_DLINFO; !! 626 (elf_addr_t) (unsigned long) u_platform); 622 #endif !! 627 } >> 628 >> 629 if (k_base_platform) { >> 630 nr = 0; >> 631 csp -= 2 * sizeof(unsigned long); >> 632 NEW_AUX_ENT(AT_BASE_PLATFORM, >> 633 (elf_addr_t) (unsigned long) u_base_platform); >> 634 } >> 635 >> 636 if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) { >> 637 nr = 0; >> 638 csp -= 2 * sizeof(unsigned long); >> 639 NEW_AUX_ENT(AT_EXECFD, bprm->interp_data); >> 640 } >> 641 >> 642 nr = 0; >> 643 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long); 623 NEW_AUX_ENT(AT_HWCAP, ELF_HWCAP); 644 NEW_AUX_ENT(AT_HWCAP, ELF_HWCAP); 624 #ifdef ELF_HWCAP2 645 #ifdef ELF_HWCAP2 625 NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2); 646 NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2); 626 #endif 647 #endif 627 NEW_AUX_ENT(AT_PAGESZ, PAGE_SIZE); 648 NEW_AUX_ENT(AT_PAGESZ, PAGE_SIZE); 628 NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC 649 NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC); 629 NEW_AUX_ENT(AT_PHDR, exec_params->p 650 NEW_AUX_ENT(AT_PHDR, exec_params->ph_addr); 630 NEW_AUX_ENT(AT_PHENT, sizeof(struct 651 NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr)); 631 NEW_AUX_ENT(AT_PHNUM, exec_params->h 652 NEW_AUX_ENT(AT_PHNUM, exec_params->hdr.e_phnum); 632 NEW_AUX_ENT(AT_BASE, interp_params- 653 NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr); 633 if (bprm->interp_flags & BINPRM_FLAGS_ !! 654 NEW_AUX_ENT(AT_FLAGS, 0); 634 flags |= AT_FLAGS_PRESERVE_ARG << 635 NEW_AUX_ENT(AT_FLAGS, flags); << 636 NEW_AUX_ENT(AT_ENTRY, exec_params->e 655 NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr); 637 NEW_AUX_ENT(AT_UID, (elf_addr_t) f 656 NEW_AUX_ENT(AT_UID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->uid)); 638 NEW_AUX_ENT(AT_EUID, (elf_addr_t) f 657 NEW_AUX_ENT(AT_EUID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->euid)); 639 NEW_AUX_ENT(AT_GID, (elf_addr_t) f 658 NEW_AUX_ENT(AT_GID, (elf_addr_t) from_kgid_munged(cred->user_ns, cred->gid)); 640 NEW_AUX_ENT(AT_EGID, (elf_addr_t) f 659 NEW_AUX_ENT(AT_EGID, (elf_addr_t) from_kgid_munged(cred->user_ns, cred->egid)); 641 NEW_AUX_ENT(AT_SECURE, bprm->secureex 660 NEW_AUX_ENT(AT_SECURE, bprm->secureexec); 642 NEW_AUX_ENT(AT_EXECFN, bprm->exec); 661 NEW_AUX_ENT(AT_EXECFN, bprm->exec); 643 if (k_platform) !! 662 644 NEW_AUX_ENT(AT_PLATFORM, !! 663 #ifdef ARCH_DLINFO 645 (elf_addr_t)(unsig !! 664 nr = 0; 646 if (k_base_platform) !! 665 csp -= AT_VECTOR_SIZE_ARCH * 2 * sizeof(unsigned long); 647 NEW_AUX_ENT(AT_BASE_PLATFORM, !! 666 648 (elf_addr_t)(unsig !! 667 /* ARCH_DLINFO must come last so platform specific code can enforce 649 if (bprm->have_execfd) !! 668 * special alignment requirements on the AUXV if necessary (eg. PPC). 650 NEW_AUX_ENT(AT_EXECFD, bprm->e !! 669 */ >> 670 ARCH_DLINFO; >> 671 #endif 651 #undef NEW_AUX_ENT 672 #undef NEW_AUX_ENT 652 /* AT_NULL is zero; clear the rest too << 653 memset(elf_info, 0, (char *)mm->saved_ << 654 sizeof(mm->saved_auxv) - (char << 655 << 656 /* And advance past the AT_NULL entry. << 657 elf_info += 2; << 658 << 659 ei_index = elf_info - (elf_addr_t *)mm << 660 csp -= ei_index * sizeof(elf_addr_t); << 661 << 662 /* Put the elf_info on the stack in th << 663 if (copy_to_user((void __user *)csp, m << 664 ei_index * sizeof(elf << 665 return -EFAULT; << 666 673 667 /* allocate room for argv[] and envv[] 674 /* allocate room for argv[] and envv[] */ 668 csp -= (bprm->envc + 1) * sizeof(elf_c 675 csp -= (bprm->envc + 1) * sizeof(elf_caddr_t); 669 envp = (elf_caddr_t __user *) csp; 676 envp = (elf_caddr_t __user *) csp; 670 csp -= (bprm->argc + 1) * sizeof(elf_c 677 csp -= (bprm->argc + 1) * sizeof(elf_caddr_t); 671 argv = (elf_caddr_t __user *) csp; 678 argv = (elf_caddr_t __user *) csp; 672 679 673 /* stack argc */ 680 /* stack argc */ 674 csp -= sizeof(unsigned long); 681 csp -= sizeof(unsigned long); 675 if (put_user(bprm->argc, (unsigned lon !! 682 __put_user(bprm->argc, (unsigned long __user *) csp); 676 return -EFAULT; << 677 683 678 BUG_ON(csp != sp); 684 BUG_ON(csp != sp); 679 685 680 /* fill in the argv[] array */ 686 /* fill in the argv[] array */ 681 #ifdef CONFIG_MMU 687 #ifdef CONFIG_MMU 682 current->mm->arg_start = bprm->p; 688 current->mm->arg_start = bprm->p; 683 #else 689 #else 684 current->mm->arg_start = current->mm-> 690 current->mm->arg_start = current->mm->start_stack - 685 (MAX_ARG_PAGES * PAGE_SIZE - b 691 (MAX_ARG_PAGES * PAGE_SIZE - bprm->p); 686 #endif 692 #endif 687 693 688 p = (char __user *) current->mm->arg_s 694 p = (char __user *) current->mm->arg_start; 689 for (loop = bprm->argc; loop > 0; loop 695 for (loop = bprm->argc; loop > 0; loop--) { 690 if (put_user((elf_caddr_t) p, !! 696 __put_user((elf_caddr_t) p, argv++); 691 return -EFAULT; << 692 len = strnlen_user(p, MAX_ARG_ 697 len = strnlen_user(p, MAX_ARG_STRLEN); 693 if (!len || len > MAX_ARG_STRL 698 if (!len || len > MAX_ARG_STRLEN) 694 return -EINVAL; 699 return -EINVAL; 695 p += len; 700 p += len; 696 } 701 } 697 if (put_user(NULL, argv)) !! 702 __put_user(NULL, argv); 698 return -EFAULT; << 699 current->mm->arg_end = (unsigned long) 703 current->mm->arg_end = (unsigned long) p; 700 704 701 /* fill in the envv[] array */ 705 /* fill in the envv[] array */ 702 current->mm->env_start = (unsigned lon 706 current->mm->env_start = (unsigned long) p; 703 for (loop = bprm->envc; loop > 0; loop 707 for (loop = bprm->envc; loop > 0; loop--) { 704 if (put_user((elf_caddr_t)(uns !! 708 __put_user((elf_caddr_t)(unsigned long) p, envp++); 705 return -EFAULT; << 706 len = strnlen_user(p, MAX_ARG_ 709 len = strnlen_user(p, MAX_ARG_STRLEN); 707 if (!len || len > MAX_ARG_STRL 710 if (!len || len > MAX_ARG_STRLEN) 708 return -EINVAL; 711 return -EINVAL; 709 p += len; 712 p += len; 710 } 713 } 711 if (put_user(NULL, envp)) !! 714 __put_user(NULL, envp); 712 return -EFAULT; << 713 current->mm->env_end = (unsigned long) 715 current->mm->env_end = (unsigned long) p; 714 716 715 mm->start_stack = (unsigned long) sp; 717 mm->start_stack = (unsigned long) sp; 716 return 0; 718 return 0; 717 } 719 } 718 720 719 /********************************************* 721 /*****************************************************************************/ 720 /* 722 /* 721 * load the appropriate binary image (executab 723 * load the appropriate binary image (executable or interpreter) into memory 722 * - we assume no MMU is available 724 * - we assume no MMU is available 723 * - if no other PIC bits are set in params->h 725 * - if no other PIC bits are set in params->hdr->e_flags 724 * - we assume that the LOADable segments in 726 * - we assume that the LOADable segments in the binary are independently relocatable 725 * - we assume R/O executable segments are s 727 * - we assume R/O executable segments are shareable 726 * - else 728 * - else 727 * - we assume the loadable parts of the ima 729 * - we assume the loadable parts of the image to require fixed displacement 728 * - the image is not shareable 730 * - the image is not shareable 729 */ 731 */ 730 static int elf_fdpic_map_file(struct elf_fdpic 732 static int elf_fdpic_map_file(struct elf_fdpic_params *params, 731 struct file *fil 733 struct file *file, 732 struct mm_struct 734 struct mm_struct *mm, 733 const char *what 735 const char *what) 734 { 736 { 735 struct elf_fdpic_loadmap *loadmap; !! 737 struct elf32_fdpic_loadmap *loadmap; 736 #ifdef CONFIG_MMU 738 #ifdef CONFIG_MMU 737 struct elf_fdpic_loadseg *mseg; !! 739 struct elf32_fdpic_loadseg *mseg; 738 unsigned long load_addr; << 739 #endif 740 #endif 740 struct elf_fdpic_loadseg *seg; !! 741 struct elf32_fdpic_loadseg *seg; 741 struct elf_phdr *phdr; !! 742 struct elf32_phdr *phdr; >> 743 unsigned long load_addr, stop; 742 unsigned nloads, tmp; 744 unsigned nloads, tmp; 743 unsigned long stop; !! 745 size_t size; 744 int loop, ret; 746 int loop, ret; 745 747 746 /* allocate a load map table */ 748 /* allocate a load map table */ 747 nloads = 0; 749 nloads = 0; 748 for (loop = 0; loop < params->hdr.e_ph 750 for (loop = 0; loop < params->hdr.e_phnum; loop++) 749 if (params->phdrs[loop].p_type 751 if (params->phdrs[loop].p_type == PT_LOAD) 750 nloads++; 752 nloads++; 751 753 752 if (nloads == 0) 754 if (nloads == 0) 753 return -ELIBBAD; 755 return -ELIBBAD; 754 756 755 loadmap = kzalloc(struct_size(loadmap, !! 757 size = sizeof(*loadmap) + nloads * sizeof(*seg); >> 758 loadmap = kzalloc(size, GFP_KERNEL); 756 if (!loadmap) 759 if (!loadmap) 757 return -ENOMEM; 760 return -ENOMEM; 758 761 759 params->loadmap = loadmap; 762 params->loadmap = loadmap; 760 763 761 loadmap->version = ELF_FDPIC_LOADMAP_V !! 764 loadmap->version = ELF32_FDPIC_LOADMAP_VERSION; 762 loadmap->nsegs = nloads; 765 loadmap->nsegs = nloads; 763 766 >> 767 load_addr = params->load_addr; >> 768 seg = loadmap->segs; >> 769 764 /* map the requested LOADs into the me 770 /* map the requested LOADs into the memory space */ 765 switch (params->flags & ELF_FDPIC_FLAG 771 switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) { 766 case ELF_FDPIC_FLAG_CONSTDISP: 772 case ELF_FDPIC_FLAG_CONSTDISP: 767 case ELF_FDPIC_FLAG_CONTIGUOUS: 773 case ELF_FDPIC_FLAG_CONTIGUOUS: 768 #ifndef CONFIG_MMU 774 #ifndef CONFIG_MMU 769 ret = elf_fdpic_map_file_const 775 ret = elf_fdpic_map_file_constdisp_on_uclinux(params, file, mm); 770 if (ret < 0) 776 if (ret < 0) 771 return ret; 777 return ret; 772 break; 778 break; 773 #endif 779 #endif 774 default: 780 default: 775 ret = elf_fdpic_map_file_by_di 781 ret = elf_fdpic_map_file_by_direct_mmap(params, file, mm); 776 if (ret < 0) 782 if (ret < 0) 777 return ret; 783 return ret; 778 break; 784 break; 779 } 785 } 780 786 781 /* map the entry point */ 787 /* map the entry point */ 782 if (params->hdr.e_entry) { 788 if (params->hdr.e_entry) { 783 seg = loadmap->segs; 789 seg = loadmap->segs; 784 for (loop = loadmap->nsegs; lo 790 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 785 if (params->hdr.e_entr 791 if (params->hdr.e_entry >= seg->p_vaddr && 786 params->hdr.e_entr 792 params->hdr.e_entry < seg->p_vaddr + seg->p_memsz) { 787 params->entry_ 793 params->entry_addr = 788 (param 794 (params->hdr.e_entry - seg->p_vaddr) + 789 seg->a 795 seg->addr; 790 break; 796 break; 791 } 797 } 792 } 798 } 793 } 799 } 794 800 795 /* determine where the program header 801 /* determine where the program header table has wound up if mapped */ 796 stop = params->hdr.e_phoff; 802 stop = params->hdr.e_phoff; 797 stop += params->hdr.e_phnum * sizeof ( 803 stop += params->hdr.e_phnum * sizeof (struct elf_phdr); 798 phdr = params->phdrs; 804 phdr = params->phdrs; 799 805 800 for (loop = 0; loop < params->hdr.e_ph 806 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 801 if (phdr->p_type != PT_LOAD) 807 if (phdr->p_type != PT_LOAD) 802 continue; 808 continue; 803 809 804 if (phdr->p_offset > params->h 810 if (phdr->p_offset > params->hdr.e_phoff || 805 phdr->p_offset + phdr->p_f 811 phdr->p_offset + phdr->p_filesz < stop) 806 continue; 812 continue; 807 813 808 seg = loadmap->segs; 814 seg = loadmap->segs; 809 for (loop = loadmap->nsegs; lo 815 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 810 if (phdr->p_vaddr >= s 816 if (phdr->p_vaddr >= seg->p_vaddr && 811 phdr->p_vaddr + ph 817 phdr->p_vaddr + phdr->p_filesz <= 812 seg->p_vaddr + seg 818 seg->p_vaddr + seg->p_memsz) { 813 params->ph_add 819 params->ph_addr = 814 (phdr- 820 (phdr->p_vaddr - seg->p_vaddr) + 815 seg->a 821 seg->addr + 816 params 822 params->hdr.e_phoff - phdr->p_offset; 817 break; 823 break; 818 } 824 } 819 } 825 } 820 break; 826 break; 821 } 827 } 822 828 823 /* determine where the dynamic section 829 /* determine where the dynamic section has wound up if there is one */ 824 phdr = params->phdrs; 830 phdr = params->phdrs; 825 for (loop = 0; loop < params->hdr.e_ph 831 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 826 if (phdr->p_type != PT_DYNAMIC 832 if (phdr->p_type != PT_DYNAMIC) 827 continue; 833 continue; 828 834 829 seg = loadmap->segs; 835 seg = loadmap->segs; 830 for (loop = loadmap->nsegs; lo 836 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 831 if (phdr->p_vaddr >= s 837 if (phdr->p_vaddr >= seg->p_vaddr && 832 phdr->p_vaddr + ph 838 phdr->p_vaddr + phdr->p_memsz <= 833 seg->p_vaddr + seg 839 seg->p_vaddr + seg->p_memsz) { 834 Elf_Dyn __user !! 840 Elf32_Dyn __user *dyn; 835 Elf_Sword d_ta !! 841 Elf32_Sword d_tag; 836 842 837 params->dynami 843 params->dynamic_addr = 838 (phdr- 844 (phdr->p_vaddr - seg->p_vaddr) + 839 seg->a 845 seg->addr; 840 846 841 /* check the d 847 /* check the dynamic section contains at least 842 * one item, a 848 * one item, and that the last item is a NULL 843 * entry */ 849 * entry */ 844 if (phdr->p_me 850 if (phdr->p_memsz == 0 || 845 phdr->p_me !! 851 phdr->p_memsz % sizeof(Elf32_Dyn) != 0) 846 goto d 852 goto dynamic_error; 847 853 848 tmp = phdr->p_ !! 854 tmp = phdr->p_memsz / sizeof(Elf32_Dyn); 849 dyn = (Elf_Dyn !! 855 dyn = (Elf32_Dyn __user *)params->dynamic_addr; 850 if (get_user(d !! 856 __get_user(d_tag, &dyn[tmp - 1].d_tag); 851 d_tag != 0 !! 857 if (d_tag != 0) 852 goto d 858 goto dynamic_error; 853 break; 859 break; 854 } 860 } 855 } 861 } 856 break; 862 break; 857 } 863 } 858 864 859 /* now elide adjacent segments in the 865 /* now elide adjacent segments in the load map on MMU linux 860 * - on uClinux the holes between may 866 * - on uClinux the holes between may actually be filled with system 861 * stuff or stuff from other process 867 * stuff or stuff from other processes 862 */ 868 */ 863 #ifdef CONFIG_MMU 869 #ifdef CONFIG_MMU 864 nloads = loadmap->nsegs; 870 nloads = loadmap->nsegs; 865 mseg = loadmap->segs; 871 mseg = loadmap->segs; 866 seg = mseg + 1; 872 seg = mseg + 1; 867 for (loop = 1; loop < nloads; loop++) 873 for (loop = 1; loop < nloads; loop++) { 868 /* see if we have a candidate 874 /* see if we have a candidate for merging */ 869 if (seg->p_vaddr - mseg->p_vad 875 if (seg->p_vaddr - mseg->p_vaddr == seg->addr - mseg->addr) { 870 load_addr = PAGE_ALIGN 876 load_addr = PAGE_ALIGN(mseg->addr + mseg->p_memsz); 871 if (load_addr == (seg- 877 if (load_addr == (seg->addr & PAGE_MASK)) { 872 mseg->p_memsz 878 mseg->p_memsz += 873 load_a 879 load_addr - 874 (mseg- 880 (mseg->addr + mseg->p_memsz); 875 mseg->p_memsz 881 mseg->p_memsz += seg->addr & ~PAGE_MASK; 876 mseg->p_memsz 882 mseg->p_memsz += seg->p_memsz; 877 loadmap->nsegs 883 loadmap->nsegs--; 878 continue; 884 continue; 879 } 885 } 880 } 886 } 881 887 882 mseg++; 888 mseg++; 883 if (mseg != seg) 889 if (mseg != seg) 884 *mseg = *seg; 890 *mseg = *seg; 885 } 891 } 886 #endif 892 #endif 887 893 888 kdebug("Mapped Object [%s]:", what); 894 kdebug("Mapped Object [%s]:", what); 889 kdebug("- elfhdr : %lx", params->elf 895 kdebug("- elfhdr : %lx", params->elfhdr_addr); 890 kdebug("- entry : %lx", params->ent 896 kdebug("- entry : %lx", params->entry_addr); 891 kdebug("- PHDR[] : %lx", params->ph_ 897 kdebug("- PHDR[] : %lx", params->ph_addr); 892 kdebug("- DYNAMIC[]: %lx", params->dyn 898 kdebug("- DYNAMIC[]: %lx", params->dynamic_addr); 893 seg = loadmap->segs; 899 seg = loadmap->segs; 894 for (loop = 0; loop < loadmap->nsegs; 900 for (loop = 0; loop < loadmap->nsegs; loop++, seg++) 895 kdebug("- LOAD[%d] : %08llx-%0 !! 901 kdebug("- LOAD[%d] : %08x-%08x [va=%x ms=%x]", 896 loop, 902 loop, 897 (unsigned long long) se !! 903 seg->addr, seg->addr + seg->p_memsz - 1, 898 (unsigned long long) se !! 904 seg->p_vaddr, seg->p_memsz); 899 (unsigned long long) se << 900 (unsigned long long) se << 901 905 902 return 0; 906 return 0; 903 907 904 dynamic_error: 908 dynamic_error: 905 printk("ELF FDPIC %s with invalid DYNA 909 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n", 906 what, file_inode(file)->i_ino); 910 what, file_inode(file)->i_ino); 907 return -ELIBBAD; 911 return -ELIBBAD; 908 } 912 } 909 913 910 /********************************************* 914 /*****************************************************************************/ 911 /* 915 /* 912 * map a file with constant displacement under 916 * map a file with constant displacement under uClinux 913 */ 917 */ 914 #ifndef CONFIG_MMU 918 #ifndef CONFIG_MMU 915 static int elf_fdpic_map_file_constdisp_on_ucl 919 static int elf_fdpic_map_file_constdisp_on_uclinux( 916 struct elf_fdpic_params *params, 920 struct elf_fdpic_params *params, 917 struct file *file, 921 struct file *file, 918 struct mm_struct *mm) 922 struct mm_struct *mm) 919 { 923 { 920 struct elf_fdpic_loadseg *seg; !! 924 struct elf32_fdpic_loadseg *seg; 921 struct elf_phdr *phdr; !! 925 struct elf32_phdr *phdr; 922 unsigned long load_addr, base = ULONG_ !! 926 unsigned long load_addr, base = ULONG_MAX, top = 0, maddr = 0, mflags; 923 int loop, ret; 927 int loop, ret; 924 928 925 load_addr = params->load_addr; 929 load_addr = params->load_addr; 926 seg = params->loadmap->segs; 930 seg = params->loadmap->segs; 927 931 928 /* determine the bounds of the contigu 932 /* determine the bounds of the contiguous overall allocation we must 929 * make */ 933 * make */ 930 phdr = params->phdrs; 934 phdr = params->phdrs; 931 for (loop = 0; loop < params->hdr.e_ph 935 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 932 if (params->phdrs[loop].p_type 936 if (params->phdrs[loop].p_type != PT_LOAD) 933 continue; 937 continue; 934 938 935 if (base > phdr->p_vaddr) 939 if (base > phdr->p_vaddr) 936 base = phdr->p_vaddr; 940 base = phdr->p_vaddr; 937 if (top < phdr->p_vaddr + phdr 941 if (top < phdr->p_vaddr + phdr->p_memsz) 938 top = phdr->p_vaddr + 942 top = phdr->p_vaddr + phdr->p_memsz; 939 } 943 } 940 944 941 /* allocate one big anon block for eve 945 /* allocate one big anon block for everything */ >> 946 mflags = MAP_PRIVATE; >> 947 if (params->flags & ELF_FDPIC_FLAG_EXECUTABLE) >> 948 mflags |= MAP_EXECUTABLE; >> 949 942 maddr = vm_mmap(NULL, load_addr, top - 950 maddr = vm_mmap(NULL, load_addr, top - base, 943 PROT_READ | PROT_WRITE !! 951 PROT_READ | PROT_WRITE | PROT_EXEC, mflags, 0); 944 if (IS_ERR_VALUE(maddr)) 952 if (IS_ERR_VALUE(maddr)) 945 return (int) maddr; 953 return (int) maddr; 946 954 947 if (load_addr != 0) 955 if (load_addr != 0) 948 load_addr += PAGE_ALIGN(top - 956 load_addr += PAGE_ALIGN(top - base); 949 957 950 /* and then load the file segments int 958 /* and then load the file segments into it */ 951 phdr = params->phdrs; 959 phdr = params->phdrs; 952 for (loop = 0; loop < params->hdr.e_ph 960 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 953 if (params->phdrs[loop].p_type 961 if (params->phdrs[loop].p_type != PT_LOAD) 954 continue; 962 continue; 955 963 956 seg->addr = maddr + (phdr->p_v 964 seg->addr = maddr + (phdr->p_vaddr - base); 957 seg->p_vaddr = phdr->p_vaddr; 965 seg->p_vaddr = phdr->p_vaddr; 958 seg->p_memsz = phdr->p_memsz; 966 seg->p_memsz = phdr->p_memsz; 959 967 960 ret = read_code(file, seg->add 968 ret = read_code(file, seg->addr, phdr->p_offset, 961 phdr->p 969 phdr->p_filesz); 962 if (ret < 0) 970 if (ret < 0) 963 return ret; 971 return ret; 964 972 965 /* map the ELF header address 973 /* map the ELF header address if in this segment */ 966 if (phdr->p_offset == 0) 974 if (phdr->p_offset == 0) 967 params->elfhdr_addr = 975 params->elfhdr_addr = seg->addr; 968 976 969 /* clear any space allocated b 977 /* clear any space allocated but not loaded */ 970 if (phdr->p_filesz < phdr->p_m 978 if (phdr->p_filesz < phdr->p_memsz) { 971 if (clear_user((void * 979 if (clear_user((void *) (seg->addr + phdr->p_filesz), 972 phdr->p 980 phdr->p_memsz - phdr->p_filesz)) 973 return -EFAULT 981 return -EFAULT; 974 } 982 } 975 983 976 if (mm) { 984 if (mm) { 977 if (phdr->p_flags & PF 985 if (phdr->p_flags & PF_X) { 978 if (!mm->start 986 if (!mm->start_code) { 979 mm->st 987 mm->start_code = seg->addr; 980 mm->en 988 mm->end_code = seg->addr + 981 989 phdr->p_memsz; 982 } 990 } 983 } else if (!mm->start_ 991 } else if (!mm->start_data) { 984 mm->start_data 992 mm->start_data = seg->addr; 985 mm->end_data = 993 mm->end_data = seg->addr + phdr->p_memsz; 986 } 994 } 987 } 995 } 988 996 989 seg++; 997 seg++; 990 } 998 } 991 999 992 return 0; 1000 return 0; 993 } 1001 } 994 #endif 1002 #endif 995 1003 996 /********************************************* 1004 /*****************************************************************************/ 997 /* 1005 /* 998 * map a binary by direct mmap() of the indivi 1006 * map a binary by direct mmap() of the individual PT_LOAD segments 999 */ 1007 */ 1000 static int elf_fdpic_map_file_by_direct_mmap( 1008 static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, 1001 1009 struct file *file, 1002 1010 struct mm_struct *mm) 1003 { 1011 { 1004 struct elf_fdpic_loadseg *seg; !! 1012 struct elf32_fdpic_loadseg *seg; 1005 struct elf_phdr *phdr; !! 1013 struct elf32_phdr *phdr; 1006 unsigned long load_addr, delta_vaddr; 1014 unsigned long load_addr, delta_vaddr; 1007 int loop, dvset; 1015 int loop, dvset; 1008 1016 1009 load_addr = params->load_addr; 1017 load_addr = params->load_addr; 1010 delta_vaddr = 0; 1018 delta_vaddr = 0; 1011 dvset = 0; 1019 dvset = 0; 1012 1020 1013 seg = params->loadmap->segs; 1021 seg = params->loadmap->segs; 1014 1022 1015 /* deal with each load segment separa 1023 /* deal with each load segment separately */ 1016 phdr = params->phdrs; 1024 phdr = params->phdrs; 1017 for (loop = 0; loop < params->hdr.e_p 1025 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 1018 unsigned long maddr, disp, ex 1026 unsigned long maddr, disp, excess, excess1; 1019 int prot = 0, flags; 1027 int prot = 0, flags; 1020 1028 1021 if (phdr->p_type != PT_LOAD) 1029 if (phdr->p_type != PT_LOAD) 1022 continue; 1030 continue; 1023 1031 1024 kdebug("[LOAD] va=%lx of=%lx 1032 kdebug("[LOAD] va=%lx of=%lx fs=%lx ms=%lx", 1025 (unsigned long) phdr-> 1033 (unsigned long) phdr->p_vaddr, 1026 (unsigned long) phdr-> 1034 (unsigned long) phdr->p_offset, 1027 (unsigned long) phdr-> 1035 (unsigned long) phdr->p_filesz, 1028 (unsigned long) phdr-> 1036 (unsigned long) phdr->p_memsz); 1029 1037 1030 /* determine the mapping para 1038 /* determine the mapping parameters */ 1031 if (phdr->p_flags & PF_R) pro 1039 if (phdr->p_flags & PF_R) prot |= PROT_READ; 1032 if (phdr->p_flags & PF_W) pro 1040 if (phdr->p_flags & PF_W) prot |= PROT_WRITE; 1033 if (phdr->p_flags & PF_X) pro 1041 if (phdr->p_flags & PF_X) prot |= PROT_EXEC; 1034 1042 1035 flags = MAP_PRIVATE; !! 1043 flags = MAP_PRIVATE | MAP_DENYWRITE; >> 1044 if (params->flags & ELF_FDPIC_FLAG_EXECUTABLE) >> 1045 flags |= MAP_EXECUTABLE; >> 1046 1036 maddr = 0; 1047 maddr = 0; 1037 1048 1038 switch (params->flags & ELF_F 1049 switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) { 1039 case ELF_FDPIC_FLAG_INDEPENDE 1050 case ELF_FDPIC_FLAG_INDEPENDENT: 1040 /* PT_LOADs are indep 1051 /* PT_LOADs are independently locatable */ 1041 break; 1052 break; 1042 1053 1043 case ELF_FDPIC_FLAG_HONOURVAD 1054 case ELF_FDPIC_FLAG_HONOURVADDR: 1044 /* the specified virt 1055 /* the specified virtual address must be honoured */ 1045 maddr = phdr->p_vaddr 1056 maddr = phdr->p_vaddr; 1046 flags |= MAP_FIXED; 1057 flags |= MAP_FIXED; 1047 break; 1058 break; 1048 1059 1049 case ELF_FDPIC_FLAG_CONSTDISP 1060 case ELF_FDPIC_FLAG_CONSTDISP: 1050 /* constant displacem 1061 /* constant displacement 1051 * - can be mapped an 1062 * - can be mapped anywhere, but must be mapped as a 1052 * unit 1063 * unit 1053 */ 1064 */ 1054 if (!dvset) { 1065 if (!dvset) { 1055 maddr = load_ 1066 maddr = load_addr; 1056 delta_vaddr = 1067 delta_vaddr = phdr->p_vaddr; 1057 dvset = 1; 1068 dvset = 1; 1058 } else { 1069 } else { 1059 maddr = load_ 1070 maddr = load_addr + phdr->p_vaddr - delta_vaddr; 1060 flags |= MAP_ 1071 flags |= MAP_FIXED; 1061 } 1072 } 1062 break; 1073 break; 1063 1074 1064 case ELF_FDPIC_FLAG_CONTIGUOU 1075 case ELF_FDPIC_FLAG_CONTIGUOUS: 1065 /* contiguity handled 1076 /* contiguity handled later */ 1066 break; 1077 break; 1067 1078 1068 default: 1079 default: 1069 BUG(); 1080 BUG(); 1070 } 1081 } 1071 1082 1072 maddr &= PAGE_MASK; 1083 maddr &= PAGE_MASK; 1073 1084 1074 /* create the mapping */ 1085 /* create the mapping */ 1075 disp = phdr->p_vaddr & ~PAGE_ 1086 disp = phdr->p_vaddr & ~PAGE_MASK; 1076 maddr = vm_mmap(file, maddr, 1087 maddr = vm_mmap(file, maddr, phdr->p_memsz + disp, prot, flags, 1077 phdr->p_offse 1088 phdr->p_offset - disp); 1078 1089 1079 kdebug("mmap[%d] <file> sz=%l !! 1090 kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx", 1080 loop, (unsigned long l !! 1091 loop, phdr->p_memsz + disp, prot, flags, 1081 prot, flags, (unsigned !! 1092 phdr->p_offset - disp, maddr); 1082 maddr); << 1083 1093 1084 if (IS_ERR_VALUE(maddr)) 1094 if (IS_ERR_VALUE(maddr)) 1085 return (int) maddr; 1095 return (int) maddr; 1086 1096 1087 if ((params->flags & ELF_FDPI 1097 if ((params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) == 1088 ELF_FDPIC_FLAG_CONTIGUOUS 1098 ELF_FDPIC_FLAG_CONTIGUOUS) 1089 load_addr += PAGE_ALI 1099 load_addr += PAGE_ALIGN(phdr->p_memsz + disp); 1090 1100 1091 seg->addr = maddr + disp; 1101 seg->addr = maddr + disp; 1092 seg->p_vaddr = phdr->p_vaddr; 1102 seg->p_vaddr = phdr->p_vaddr; 1093 seg->p_memsz = phdr->p_memsz; 1103 seg->p_memsz = phdr->p_memsz; 1094 1104 1095 /* map the ELF header address 1105 /* map the ELF header address if in this segment */ 1096 if (phdr->p_offset == 0) 1106 if (phdr->p_offset == 0) 1097 params->elfhdr_addr = 1107 params->elfhdr_addr = seg->addr; 1098 1108 1099 /* clear the bit between begi 1109 /* clear the bit between beginning of mapping and beginning of 1100 * PT_LOAD */ 1110 * PT_LOAD */ 1101 if (prot & PROT_WRITE && disp 1111 if (prot & PROT_WRITE && disp > 0) { 1102 kdebug("clear[%d] ad= 1112 kdebug("clear[%d] ad=%lx sz=%lx", loop, maddr, disp); 1103 if (clear_user((void 1113 if (clear_user((void __user *) maddr, disp)) 1104 return -EFAUL 1114 return -EFAULT; 1105 maddr += disp; 1115 maddr += disp; 1106 } 1116 } 1107 1117 1108 /* clear any space allocated 1118 /* clear any space allocated but not loaded 1109 * - on uClinux we can just c 1119 * - on uClinux we can just clear the lot 1110 * - on MMU linux we'll get a 1120 * - on MMU linux we'll get a SIGBUS beyond the last page 1111 * extant in the file 1121 * extant in the file 1112 */ 1122 */ 1113 excess = phdr->p_memsz - phdr 1123 excess = phdr->p_memsz - phdr->p_filesz; 1114 excess1 = PAGE_SIZE - ((maddr 1124 excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK); 1115 1125 1116 #ifdef CONFIG_MMU 1126 #ifdef CONFIG_MMU 1117 if (excess > excess1) { 1127 if (excess > excess1) { 1118 unsigned long xaddr = 1128 unsigned long xaddr = maddr + phdr->p_filesz + excess1; 1119 unsigned long xmaddr; 1129 unsigned long xmaddr; 1120 1130 1121 flags |= MAP_FIXED | 1131 flags |= MAP_FIXED | MAP_ANONYMOUS; 1122 xmaddr = vm_mmap(NULL 1132 xmaddr = vm_mmap(NULL, xaddr, excess - excess1, 1123 prot 1133 prot, flags, 0); 1124 1134 1125 kdebug("mmap[%d] <ano 1135 kdebug("mmap[%d] <anon>" 1126 " ad=%lx sz=%l 1136 " ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx", 1127 loop, xaddr, e 1137 loop, xaddr, excess - excess1, prot, flags, 1128 xmaddr); 1138 xmaddr); 1129 1139 1130 if (xmaddr != xaddr) 1140 if (xmaddr != xaddr) 1131 return -ENOME 1141 return -ENOMEM; 1132 } 1142 } 1133 1143 1134 if (prot & PROT_WRITE && exce 1144 if (prot & PROT_WRITE && excess1 > 0) { 1135 kdebug("clear[%d] ad= 1145 kdebug("clear[%d] ad=%lx sz=%lx", 1136 loop, maddr + 1146 loop, maddr + phdr->p_filesz, excess1); 1137 if (clear_user((void 1147 if (clear_user((void __user *) maddr + phdr->p_filesz, 1138 excess 1148 excess1)) 1139 return -EFAUL 1149 return -EFAULT; 1140 } 1150 } 1141 1151 1142 #else 1152 #else 1143 if (excess > 0) { 1153 if (excess > 0) { 1144 kdebug("clear[%d] ad= !! 1154 kdebug("clear[%d] ad=%lx sz=%lx", 1145 (unsigned long !! 1155 loop, maddr + phdr->p_filesz, excess); 1146 excess); << 1147 if (clear_user((void 1156 if (clear_user((void *) maddr + phdr->p_filesz, excess)) 1148 return -EFAUL 1157 return -EFAULT; 1149 } 1158 } 1150 #endif 1159 #endif 1151 1160 1152 if (mm) { 1161 if (mm) { 1153 if (phdr->p_flags & P 1162 if (phdr->p_flags & PF_X) { 1154 if (!mm->star 1163 if (!mm->start_code) { 1155 mm->s 1164 mm->start_code = maddr; 1156 mm->e 1165 mm->end_code = maddr + phdr->p_memsz; 1157 } 1166 } 1158 } else if (!mm->start 1167 } else if (!mm->start_data) { 1159 mm->start_dat 1168 mm->start_data = maddr; 1160 mm->end_data 1169 mm->end_data = maddr + phdr->p_memsz; 1161 } 1170 } 1162 } 1171 } 1163 1172 1164 seg++; 1173 seg++; 1165 } 1174 } 1166 1175 1167 return 0; 1176 return 0; 1168 } 1177 } 1169 1178 1170 /******************************************** 1179 /*****************************************************************************/ 1171 /* 1180 /* 1172 * ELF-FDPIC core dumper 1181 * ELF-FDPIC core dumper 1173 * 1182 * 1174 * Modelled on fs/exec.c:aout_core_dump() 1183 * Modelled on fs/exec.c:aout_core_dump() 1175 * Jeremy Fitzhardinge <jeremy@sw.oz.au> 1184 * Jeremy Fitzhardinge <jeremy@sw.oz.au> 1176 * 1185 * 1177 * Modelled on fs/binfmt_elf.c core dumper 1186 * Modelled on fs/binfmt_elf.c core dumper 1178 */ 1187 */ 1179 #ifdef CONFIG_ELF_CORE 1188 #ifdef CONFIG_ELF_CORE 1180 1189 1181 struct elf_prstatus_fdpic !! 1190 /* >> 1191 * Decide whether a segment is worth dumping; default is yes to be >> 1192 * sure (missing info is worse than too much; etc). >> 1193 * Personally I'd include everything, and use the coredump limit... >> 1194 * >> 1195 * I think we should skip something. But I am not sure how. H.J. >> 1196 */ >> 1197 static int maydump(struct vm_area_struct *vma, unsigned long mm_flags) 1182 { 1198 { 1183 struct elf_prstatus_common commo !! 1199 int dump_ok; 1184 elf_gregset_t pr_reg; /* GP registe !! 1200 1185 /* When using FDPIC, the loadmap addr !! 1201 /* Do not dump I/O mapped devices or special mappings */ 1186 * to GDB in order for GDB to do the !! 1202 if (vma->vm_flags & VM_IO) { 1187 * fields (below) used to communicate !! 1203 kdcore("%08lx: %08lx: no (IO)", vma->vm_start, vma->vm_flags); 1188 * immediately after ``pr_reg'', so t !! 1204 return 0; 1189 * be viewed as part of the register !! 1205 } >> 1206 >> 1207 /* If we may not read the contents, don't allow us to dump >> 1208 * them either. "dump_write()" can't handle it anyway. 1190 */ 1209 */ 1191 unsigned long pr_exec_fdpic_loadmap; !! 1210 if (!(vma->vm_flags & VM_READ)) { 1192 unsigned long pr_interp_fdpic_loadmap !! 1211 kdcore("%08lx: %08lx: no (!read)", vma->vm_start, vma->vm_flags); 1193 int pr_fpvalid; /* True if ma !! 1212 return 0; 1194 }; !! 1213 } >> 1214 >> 1215 /* support for DAX */ >> 1216 if (vma_is_dax(vma)) { >> 1217 if (vma->vm_flags & VM_SHARED) { >> 1218 dump_ok = test_bit(MMF_DUMP_DAX_SHARED, &mm_flags); >> 1219 kdcore("%08lx: %08lx: %s (DAX shared)", vma->vm_start, >> 1220 vma->vm_flags, dump_ok ? "yes" : "no"); >> 1221 } else { >> 1222 dump_ok = test_bit(MMF_DUMP_DAX_PRIVATE, &mm_flags); >> 1223 kdcore("%08lx: %08lx: %s (DAX private)", vma->vm_start, >> 1224 vma->vm_flags, dump_ok ? "yes" : "no"); >> 1225 } >> 1226 return dump_ok; >> 1227 } >> 1228 >> 1229 /* By default, dump shared memory if mapped from an anonymous file. */ >> 1230 if (vma->vm_flags & VM_SHARED) { >> 1231 if (file_inode(vma->vm_file)->i_nlink == 0) { >> 1232 dump_ok = test_bit(MMF_DUMP_ANON_SHARED, &mm_flags); >> 1233 kdcore("%08lx: %08lx: %s (share)", vma->vm_start, >> 1234 vma->vm_flags, dump_ok ? "yes" : "no"); >> 1235 return dump_ok; >> 1236 } >> 1237 >> 1238 dump_ok = test_bit(MMF_DUMP_MAPPED_SHARED, &mm_flags); >> 1239 kdcore("%08lx: %08lx: %s (share)", vma->vm_start, >> 1240 vma->vm_flags, dump_ok ? "yes" : "no"); >> 1241 return dump_ok; >> 1242 } >> 1243 >> 1244 #ifdef CONFIG_MMU >> 1245 /* By default, if it hasn't been written to, don't write it out */ >> 1246 if (!vma->anon_vma) { >> 1247 dump_ok = test_bit(MMF_DUMP_MAPPED_PRIVATE, &mm_flags); >> 1248 kdcore("%08lx: %08lx: %s (!anon)", vma->vm_start, >> 1249 vma->vm_flags, dump_ok ? "yes" : "no"); >> 1250 return dump_ok; >> 1251 } >> 1252 #endif >> 1253 >> 1254 dump_ok = test_bit(MMF_DUMP_ANON_PRIVATE, &mm_flags); >> 1255 kdcore("%08lx: %08lx: %s", vma->vm_start, vma->vm_flags, >> 1256 dump_ok ? "yes" : "no"); >> 1257 return dump_ok; >> 1258 } 1195 1259 1196 /* An ELF note in memory */ 1260 /* An ELF note in memory */ 1197 struct memelfnote 1261 struct memelfnote 1198 { 1262 { 1199 const char *name; 1263 const char *name; 1200 int type; 1264 int type; 1201 unsigned int datasz; 1265 unsigned int datasz; 1202 void *data; 1266 void *data; 1203 }; 1267 }; 1204 1268 1205 static int notesize(struct memelfnote *en) 1269 static int notesize(struct memelfnote *en) 1206 { 1270 { 1207 int sz; 1271 int sz; 1208 1272 1209 sz = sizeof(struct elf_note); 1273 sz = sizeof(struct elf_note); 1210 sz += roundup(strlen(en->name) + 1, 4 1274 sz += roundup(strlen(en->name) + 1, 4); 1211 sz += roundup(en->datasz, 4); 1275 sz += roundup(en->datasz, 4); 1212 1276 1213 return sz; 1277 return sz; 1214 } 1278 } 1215 1279 1216 /* #define DEBUG */ 1280 /* #define DEBUG */ 1217 1281 1218 static int writenote(struct memelfnote *men, 1282 static int writenote(struct memelfnote *men, struct coredump_params *cprm) 1219 { 1283 { 1220 struct elf_note en; 1284 struct elf_note en; 1221 en.n_namesz = strlen(men->name) + 1; 1285 en.n_namesz = strlen(men->name) + 1; 1222 en.n_descsz = men->datasz; 1286 en.n_descsz = men->datasz; 1223 en.n_type = men->type; 1287 en.n_type = men->type; 1224 1288 1225 return dump_emit(cprm, &en, sizeof(en 1289 return dump_emit(cprm, &en, sizeof(en)) && 1226 dump_emit(cprm, men->name, en 1290 dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && 1227 dump_emit(cprm, men->data, me 1291 dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); 1228 } 1292 } 1229 1293 1230 static inline void fill_elf_fdpic_header(stru 1294 static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) 1231 { 1295 { 1232 memcpy(elf->e_ident, ELFMAG, SELFMAG) 1296 memcpy(elf->e_ident, ELFMAG, SELFMAG); 1233 elf->e_ident[EI_CLASS] = ELF_CLASS; 1297 elf->e_ident[EI_CLASS] = ELF_CLASS; 1234 elf->e_ident[EI_DATA] = ELF_DATA; 1298 elf->e_ident[EI_DATA] = ELF_DATA; 1235 elf->e_ident[EI_VERSION] = EV_CURRENT 1299 elf->e_ident[EI_VERSION] = EV_CURRENT; 1236 elf->e_ident[EI_OSABI] = ELF_OSABI; 1300 elf->e_ident[EI_OSABI] = ELF_OSABI; 1237 memset(elf->e_ident+EI_PAD, 0, EI_NID 1301 memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD); 1238 1302 1239 elf->e_type = ET_CORE; 1303 elf->e_type = ET_CORE; 1240 elf->e_machine = ELF_ARCH; 1304 elf->e_machine = ELF_ARCH; 1241 elf->e_version = EV_CURRENT; 1305 elf->e_version = EV_CURRENT; 1242 elf->e_entry = 0; 1306 elf->e_entry = 0; 1243 elf->e_phoff = sizeof(struct elfhdr); 1307 elf->e_phoff = sizeof(struct elfhdr); 1244 elf->e_shoff = 0; 1308 elf->e_shoff = 0; 1245 elf->e_flags = ELF_FDPIC_CORE_EFLAGS; 1309 elf->e_flags = ELF_FDPIC_CORE_EFLAGS; 1246 elf->e_ehsize = sizeof(struct elfhdr) 1310 elf->e_ehsize = sizeof(struct elfhdr); 1247 elf->e_phentsize = sizeof(struct elf_ 1311 elf->e_phentsize = sizeof(struct elf_phdr); 1248 elf->e_phnum = segs; 1312 elf->e_phnum = segs; 1249 elf->e_shentsize = 0; 1313 elf->e_shentsize = 0; 1250 elf->e_shnum = 0; 1314 elf->e_shnum = 0; 1251 elf->e_shstrndx = 0; 1315 elf->e_shstrndx = 0; 1252 return; 1316 return; 1253 } 1317 } 1254 1318 1255 static inline void fill_elf_note_phdr(struct 1319 static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset) 1256 { 1320 { 1257 phdr->p_type = PT_NOTE; 1321 phdr->p_type = PT_NOTE; 1258 phdr->p_offset = offset; 1322 phdr->p_offset = offset; 1259 phdr->p_vaddr = 0; 1323 phdr->p_vaddr = 0; 1260 phdr->p_paddr = 0; 1324 phdr->p_paddr = 0; 1261 phdr->p_filesz = sz; 1325 phdr->p_filesz = sz; 1262 phdr->p_memsz = 0; 1326 phdr->p_memsz = 0; 1263 phdr->p_flags = 0; 1327 phdr->p_flags = 0; 1264 phdr->p_align = 4; !! 1328 phdr->p_align = 0; 1265 return; 1329 return; 1266 } 1330 } 1267 1331 1268 static inline void fill_note(struct memelfnot 1332 static inline void fill_note(struct memelfnote *note, const char *name, int type, 1269 unsigned int sz, void *data) 1333 unsigned int sz, void *data) 1270 { 1334 { 1271 note->name = name; 1335 note->name = name; 1272 note->type = type; 1336 note->type = type; 1273 note->datasz = sz; 1337 note->datasz = sz; 1274 note->data = data; 1338 note->data = data; 1275 return; 1339 return; 1276 } 1340 } 1277 1341 1278 /* 1342 /* 1279 * fill up all the fields in prstatus from th 1343 * fill up all the fields in prstatus from the given task struct, except 1280 * registers which need to be filled up separ 1344 * registers which need to be filled up separately. 1281 */ 1345 */ 1282 static void fill_prstatus(struct elf_prstatus !! 1346 static void fill_prstatus(struct elf_prstatus *prstatus, 1283 struct task_struct 1347 struct task_struct *p, long signr) 1284 { 1348 { 1285 prstatus->pr_info.si_signo = prstatus 1349 prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; 1286 prstatus->pr_sigpend = p->pending.sig 1350 prstatus->pr_sigpend = p->pending.signal.sig[0]; 1287 prstatus->pr_sighold = p->blocked.sig 1351 prstatus->pr_sighold = p->blocked.sig[0]; 1288 rcu_read_lock(); 1352 rcu_read_lock(); 1289 prstatus->pr_ppid = task_pid_vnr(rcu_ 1353 prstatus->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent)); 1290 rcu_read_unlock(); 1354 rcu_read_unlock(); 1291 prstatus->pr_pid = task_pid_vnr(p); 1355 prstatus->pr_pid = task_pid_vnr(p); 1292 prstatus->pr_pgrp = task_pgrp_vnr(p); 1356 prstatus->pr_pgrp = task_pgrp_vnr(p); 1293 prstatus->pr_sid = task_session_vnr(p 1357 prstatus->pr_sid = task_session_vnr(p); 1294 if (thread_group_leader(p)) { 1358 if (thread_group_leader(p)) { 1295 struct task_cputime cputime; 1359 struct task_cputime cputime; 1296 1360 1297 /* 1361 /* 1298 * This is the record for the 1362 * This is the record for the group leader. It shows the 1299 * group-wide total, not its 1363 * group-wide total, not its individual thread total. 1300 */ 1364 */ 1301 thread_group_cputime(p, &cput 1365 thread_group_cputime(p, &cputime); 1302 prstatus->pr_utime = ns_to_ke !! 1366 prstatus->pr_utime = ns_to_timeval(cputime.utime); 1303 prstatus->pr_stime = ns_to_ke !! 1367 prstatus->pr_stime = ns_to_timeval(cputime.stime); 1304 } else { 1368 } else { 1305 u64 utime, stime; 1369 u64 utime, stime; 1306 1370 1307 task_cputime(p, &utime, &stim 1371 task_cputime(p, &utime, &stime); 1308 prstatus->pr_utime = ns_to_ke !! 1372 prstatus->pr_utime = ns_to_timeval(utime); 1309 prstatus->pr_stime = ns_to_ke !! 1373 prstatus->pr_stime = ns_to_timeval(stime); 1310 } 1374 } 1311 prstatus->pr_cutime = ns_to_kernel_ol !! 1375 prstatus->pr_cutime = ns_to_timeval(p->signal->cutime); 1312 prstatus->pr_cstime = ns_to_kernel_ol !! 1376 prstatus->pr_cstime = ns_to_timeval(p->signal->cstime); >> 1377 >> 1378 prstatus->pr_exec_fdpic_loadmap = p->mm->context.exec_fdpic_loadmap; >> 1379 prstatus->pr_interp_fdpic_loadmap = p->mm->context.interp_fdpic_loadmap; 1313 } 1380 } 1314 1381 1315 static int fill_psinfo(struct elf_prpsinfo *p 1382 static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, 1316 struct mm_struct *mm) 1383 struct mm_struct *mm) 1317 { 1384 { 1318 const struct cred *cred; 1385 const struct cred *cred; 1319 unsigned int i, len; 1386 unsigned int i, len; 1320 unsigned int state; << 1321 1387 1322 /* first copy the parameters from use 1388 /* first copy the parameters from user space */ 1323 memset(psinfo, 0, sizeof(struct elf_p 1389 memset(psinfo, 0, sizeof(struct elf_prpsinfo)); 1324 1390 1325 len = mm->arg_end - mm->arg_start; 1391 len = mm->arg_end - mm->arg_start; 1326 if (len >= ELF_PRARGSZ) 1392 if (len >= ELF_PRARGSZ) 1327 len = ELF_PRARGSZ - 1; 1393 len = ELF_PRARGSZ - 1; 1328 if (copy_from_user(&psinfo->pr_psargs 1394 if (copy_from_user(&psinfo->pr_psargs, 1329 (const char __user 1395 (const char __user *) mm->arg_start, len)) 1330 return -EFAULT; 1396 return -EFAULT; 1331 for (i = 0; i < len; i++) 1397 for (i = 0; i < len; i++) 1332 if (psinfo->pr_psargs[i] == 0 1398 if (psinfo->pr_psargs[i] == 0) 1333 psinfo->pr_psargs[i] 1399 psinfo->pr_psargs[i] = ' '; 1334 psinfo->pr_psargs[len] = 0; 1400 psinfo->pr_psargs[len] = 0; 1335 1401 1336 rcu_read_lock(); 1402 rcu_read_lock(); 1337 psinfo->pr_ppid = task_pid_vnr(rcu_de 1403 psinfo->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent)); 1338 rcu_read_unlock(); 1404 rcu_read_unlock(); 1339 psinfo->pr_pid = task_pid_vnr(p); 1405 psinfo->pr_pid = task_pid_vnr(p); 1340 psinfo->pr_pgrp = task_pgrp_vnr(p); 1406 psinfo->pr_pgrp = task_pgrp_vnr(p); 1341 psinfo->pr_sid = task_session_vnr(p); 1407 psinfo->pr_sid = task_session_vnr(p); 1342 1408 1343 state = READ_ONCE(p->__state); !! 1409 i = p->state ? ffz(~p->state) + 1 : 0; 1344 i = state ? ffz(~state) + 1 : 0; << 1345 psinfo->pr_state = i; 1410 psinfo->pr_state = i; 1346 psinfo->pr_sname = (i > 5) ? '.' : "R 1411 psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i]; 1347 psinfo->pr_zomb = psinfo->pr_sname == 1412 psinfo->pr_zomb = psinfo->pr_sname == 'Z'; 1348 psinfo->pr_nice = task_nice(p); 1413 psinfo->pr_nice = task_nice(p); 1349 psinfo->pr_flag = p->flags; 1414 psinfo->pr_flag = p->flags; 1350 rcu_read_lock(); 1415 rcu_read_lock(); 1351 cred = __task_cred(p); 1416 cred = __task_cred(p); 1352 SET_UID(psinfo->pr_uid, from_kuid_mun 1417 SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid)); 1353 SET_GID(psinfo->pr_gid, from_kgid_mun 1418 SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid)); 1354 rcu_read_unlock(); 1419 rcu_read_unlock(); 1355 get_task_comm(psinfo->pr_fname, p); !! 1420 strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname)); 1356 1421 1357 return 0; 1422 return 0; 1358 } 1423 } 1359 1424 1360 /* Here is the structure in which status of e 1425 /* Here is the structure in which status of each thread is captured. */ 1361 struct elf_thread_status 1426 struct elf_thread_status 1362 { 1427 { 1363 struct elf_thread_status *next; !! 1428 struct list_head list; 1364 struct elf_prstatus_fdpic prstatus; !! 1429 struct elf_prstatus prstatus; /* NT_PRSTATUS */ 1365 elf_fpregset_t fpu; /* NT 1430 elf_fpregset_t fpu; /* NT_PRFPREG */ 1366 struct memelfnote notes[2]; !! 1431 struct task_struct *thread; >> 1432 #ifdef ELF_CORE_COPY_XFPREGS >> 1433 elf_fpxregset_t xfpu; /* ELF_CORE_XFPREG_TYPE */ >> 1434 #endif >> 1435 struct memelfnote notes[3]; 1367 int num_notes; 1436 int num_notes; 1368 }; 1437 }; 1369 1438 1370 /* 1439 /* 1371 * In order to add the specific thread inform 1440 * In order to add the specific thread information for the elf file format, 1372 * we need to keep a linked list of every thr 1441 * we need to keep a linked list of every thread's pr_status and then create 1373 * a single section for them in the final cor 1442 * a single section for them in the final core file. 1374 */ 1443 */ 1375 static struct elf_thread_status *elf_dump_thr !! 1444 static int elf_dump_thread_status(long signr, struct elf_thread_status *t) 1376 { 1445 { 1377 const struct user_regset_view *view = !! 1446 struct task_struct *p = t->thread; 1378 struct elf_thread_status *t; !! 1447 int sz = 0; 1379 int i, ret; !! 1448 1380 !! 1449 t->num_notes = 0; 1381 t = kzalloc(sizeof(struct elf_thread_ !! 1450 1382 if (!t) !! 1451 fill_prstatus(&t->prstatus, p, signr); 1383 return t; !! 1452 elf_core_copy_task_regs(p, &t->prstatus.pr_reg); 1384 << 1385 fill_prstatus(&t->prstatus.common, p, << 1386 t->prstatus.pr_exec_fdpic_loadmap = p << 1387 t->prstatus.pr_interp_fdpic_loadmap = << 1388 regset_get(p, &view->regsets[0], << 1389 sizeof(t->prstatus.pr_reg) << 1390 1453 1391 fill_note(&t->notes[0], "CORE", NT_PR 1454 fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), 1392 &t->prstatus); 1455 &t->prstatus); 1393 t->num_notes++; 1456 t->num_notes++; 1394 *sz += notesize(&t->notes[0]); !! 1457 sz += notesize(&t->notes[0]); 1395 << 1396 for (i = 1; i < view->n; ++i) { << 1397 const struct user_regset *reg << 1398 if (regset->core_note_type != << 1399 continue; << 1400 if (regset->active && regset- << 1401 continue; << 1402 ret = regset_get(p, regset, s << 1403 if (ret >= 0) << 1404 t->prstatus.pr_fpvali << 1405 break; << 1406 } << 1407 1458 >> 1459 t->prstatus.pr_fpvalid = elf_core_copy_task_fpregs(p, NULL, &t->fpu); 1408 if (t->prstatus.pr_fpvalid) { 1460 if (t->prstatus.pr_fpvalid) { 1409 fill_note(&t->notes[1], "CORE 1461 fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu), 1410 &t->fpu); 1462 &t->fpu); 1411 t->num_notes++; 1463 t->num_notes++; 1412 *sz += notesize(&t->notes[1]) !! 1464 sz += notesize(&t->notes[1]); >> 1465 } >> 1466 >> 1467 #ifdef ELF_CORE_COPY_XFPREGS >> 1468 if (elf_core_copy_task_xfpregs(p, &t->xfpu)) { >> 1469 fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE, >> 1470 sizeof(t->xfpu), &t->xfpu); >> 1471 t->num_notes++; >> 1472 sz += notesize(&t->notes[2]); 1413 } 1473 } 1414 return t; !! 1474 #endif >> 1475 return sz; 1415 } 1476 } 1416 1477 1417 static void fill_extnum_info(struct elfhdr *e 1478 static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum, 1418 elf_addr_t e_sho 1479 elf_addr_t e_shoff, int segs) 1419 { 1480 { 1420 elf->e_shoff = e_shoff; 1481 elf->e_shoff = e_shoff; 1421 elf->e_shentsize = sizeof(*shdr4extnu 1482 elf->e_shentsize = sizeof(*shdr4extnum); 1422 elf->e_shnum = 1; 1483 elf->e_shnum = 1; 1423 elf->e_shstrndx = SHN_UNDEF; 1484 elf->e_shstrndx = SHN_UNDEF; 1424 1485 1425 memset(shdr4extnum, 0, sizeof(*shdr4e 1486 memset(shdr4extnum, 0, sizeof(*shdr4extnum)); 1426 1487 1427 shdr4extnum->sh_type = SHT_NULL; 1488 shdr4extnum->sh_type = SHT_NULL; 1428 shdr4extnum->sh_size = elf->e_shnum; 1489 shdr4extnum->sh_size = elf->e_shnum; 1429 shdr4extnum->sh_link = elf->e_shstrnd 1490 shdr4extnum->sh_link = elf->e_shstrndx; 1430 shdr4extnum->sh_info = segs; 1491 shdr4extnum->sh_info = segs; 1431 } 1492 } 1432 1493 1433 /* 1494 /* 1434 * dump the segments for an MMU process 1495 * dump the segments for an MMU process 1435 */ 1496 */ 1436 static bool elf_fdpic_dump_segments(struct co !! 1497 static bool elf_fdpic_dump_segments(struct coredump_params *cprm) 1437 struct co << 1438 int vma_c << 1439 { 1498 { 1440 int i; !! 1499 struct vm_area_struct *vma; 1441 1500 1442 for (i = 0; i < vma_count; i++) { !! 1501 for (vma = current->mm->mmap; vma; vma = vma->vm_next) { 1443 struct core_vma_metadata *met !! 1502 #ifdef CONFIG_MMU >> 1503 unsigned long addr; >> 1504 #endif >> 1505 >> 1506 if (!maydump(vma, cprm->mm_flags)) >> 1507 continue; 1444 1508 1445 if (!dump_user_range(cprm, me !! 1509 #ifdef CONFIG_MMU >> 1510 for (addr = vma->vm_start; addr < vma->vm_end; >> 1511 addr += PAGE_SIZE) { >> 1512 bool res; >> 1513 struct page *page = get_dump_page(addr); >> 1514 if (page) { >> 1515 void *kaddr = kmap(page); >> 1516 res = dump_emit(cprm, kaddr, PAGE_SIZE); >> 1517 kunmap(page); >> 1518 put_page(page); >> 1519 } else { >> 1520 res = dump_skip(cprm, PAGE_SIZE); >> 1521 } >> 1522 if (!res) >> 1523 return false; >> 1524 } >> 1525 #else >> 1526 if (!dump_emit(cprm, (void *) vma->vm_start, >> 1527 vma->vm_end - vma->vm_start)) 1446 return false; 1528 return false; >> 1529 #endif 1447 } 1530 } 1448 return true; 1531 return true; 1449 } 1532 } 1450 1533 >> 1534 static size_t elf_core_vma_data_size(unsigned long mm_flags) >> 1535 { >> 1536 struct vm_area_struct *vma; >> 1537 size_t size = 0; >> 1538 >> 1539 for (vma = current->mm->mmap; vma; vma = vma->vm_next) >> 1540 if (maydump(vma, mm_flags)) >> 1541 size += vma->vm_end - vma->vm_start; >> 1542 return size; >> 1543 } >> 1544 1451 /* 1545 /* 1452 * Actual dumper 1546 * Actual dumper 1453 * 1547 * 1454 * This is a two-pass process; first we find 1548 * This is a two-pass process; first we find the offsets of the bits, 1455 * and then they are actually written out. I 1549 * and then they are actually written out. If we run out of core limit 1456 * we just truncate. 1550 * we just truncate. 1457 */ 1551 */ 1458 static int elf_fdpic_core_dump(struct coredum 1552 static int elf_fdpic_core_dump(struct coredump_params *cprm) 1459 { 1553 { >> 1554 #define NUM_NOTES 6 1460 int has_dumped = 0; 1555 int has_dumped = 0; >> 1556 mm_segment_t fs; 1461 int segs; 1557 int segs; 1462 int i; 1558 int i; >> 1559 struct vm_area_struct *vma; 1463 struct elfhdr *elf = NULL; 1560 struct elfhdr *elf = NULL; 1464 loff_t offset = 0, dataoff; 1561 loff_t offset = 0, dataoff; 1465 struct memelfnote psinfo_note, auxv_n !! 1562 int numnote; >> 1563 struct memelfnote *notes = NULL; >> 1564 struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ 1466 struct elf_prpsinfo *psinfo = NULL; 1565 struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */ 1467 struct elf_thread_status *thread_list !! 1566 LIST_HEAD(thread_list); >> 1567 struct list_head *t; >> 1568 elf_fpregset_t *fpu = NULL; >> 1569 #ifdef ELF_CORE_COPY_XFPREGS >> 1570 elf_fpxregset_t *xfpu = NULL; >> 1571 #endif 1468 int thread_status_size = 0; 1572 int thread_status_size = 0; 1469 elf_addr_t *auxv; 1573 elf_addr_t *auxv; 1470 struct elf_phdr *phdr4note = NULL; 1574 struct elf_phdr *phdr4note = NULL; 1471 struct elf_shdr *shdr4extnum = NULL; 1575 struct elf_shdr *shdr4extnum = NULL; 1472 Elf_Half e_phnum; 1576 Elf_Half e_phnum; 1473 elf_addr_t e_shoff; 1577 elf_addr_t e_shoff; 1474 struct core_thread *ct; 1578 struct core_thread *ct; 1475 struct elf_thread_status *tmp; 1579 struct elf_thread_status *tmp; 1476 1580 >> 1581 /* >> 1582 * We no longer stop all VM operations. >> 1583 * >> 1584 * This is because those proceses that could possibly change map_count >> 1585 * or the mmap / vma pages are now blocked in do_exit on current >> 1586 * finishing this core dump. >> 1587 * >> 1588 * Only ptrace can touch these memory addresses, but it doesn't change >> 1589 * the map_count or the pages allocated. So no possibility of crashing >> 1590 * exists while dumping the mm->vm_next areas to the core file. >> 1591 */ >> 1592 1477 /* alloc memory for large data struct 1593 /* alloc memory for large data structures: too large to be on stack */ 1478 elf = kmalloc(sizeof(*elf), GFP_KERNE 1594 elf = kmalloc(sizeof(*elf), GFP_KERNEL); 1479 if (!elf) 1595 if (!elf) 1480 goto end_coredump; !! 1596 goto cleanup; >> 1597 prstatus = kzalloc(sizeof(*prstatus), GFP_KERNEL); >> 1598 if (!prstatus) >> 1599 goto cleanup; 1481 psinfo = kmalloc(sizeof(*psinfo), GFP 1600 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); 1482 if (!psinfo) 1601 if (!psinfo) 1483 goto end_coredump; !! 1602 goto cleanup; >> 1603 notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote), >> 1604 GFP_KERNEL); >> 1605 if (!notes) >> 1606 goto cleanup; >> 1607 fpu = kmalloc(sizeof(*fpu), GFP_KERNEL); >> 1608 if (!fpu) >> 1609 goto cleanup; >> 1610 #ifdef ELF_CORE_COPY_XFPREGS >> 1611 xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL); >> 1612 if (!xfpu) >> 1613 goto cleanup; >> 1614 #endif 1484 1615 1485 for (ct = current->signal->core_state !! 1616 for (ct = current->mm->core_state->dumper.next; 1486 ct; c 1617 ct; ct = ct->next) { 1487 tmp = elf_dump_thread_status( !! 1618 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 1488 << 1489 if (!tmp) 1619 if (!tmp) 1490 goto end_coredump; !! 1620 goto cleanup; >> 1621 >> 1622 tmp->thread = ct->task; >> 1623 list_add(&tmp->list, &thread_list); >> 1624 } 1491 1625 1492 tmp->next = thread_list; !! 1626 list_for_each(t, &thread_list) { 1493 thread_list = tmp; !! 1627 struct elf_thread_status *tmp; >> 1628 int sz; >> 1629 >> 1630 tmp = list_entry(t, struct elf_thread_status, list); >> 1631 sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp); >> 1632 thread_status_size += sz; 1494 } 1633 } 1495 1634 1496 /* now collect the dump for the curre 1635 /* now collect the dump for the current */ 1497 tmp = elf_dump_thread_status(cprm->si !! 1636 fill_prstatus(prstatus, current, cprm->siginfo->si_signo); 1498 current, !! 1637 elf_core_copy_regs(&prstatus->pr_reg, cprm->regs); 1499 if (!tmp) << 1500 goto end_coredump; << 1501 tmp->next = thread_list; << 1502 thread_list = tmp; << 1503 1638 1504 segs = cprm->vma_count + elf_core_ext !! 1639 segs = current->mm->map_count; >> 1640 segs += elf_core_extra_phdrs(); 1505 1641 1506 /* for notes section */ 1642 /* for notes section */ 1507 segs++; 1643 segs++; 1508 1644 1509 /* If segs > PN_XNUM(0xffff), then e_ 1645 /* If segs > PN_XNUM(0xffff), then e_phnum overflows. To avoid 1510 * this, kernel supports extended num 1646 * this, kernel supports extended numbering. Have a look at 1511 * include/linux/elf.h for further in 1647 * include/linux/elf.h for further information. */ 1512 e_phnum = segs > PN_XNUM ? PN_XNUM : 1648 e_phnum = segs > PN_XNUM ? PN_XNUM : segs; 1513 1649 1514 /* Set up header */ 1650 /* Set up header */ 1515 fill_elf_fdpic_header(elf, e_phnum); 1651 fill_elf_fdpic_header(elf, e_phnum); 1516 1652 1517 has_dumped = 1; 1653 has_dumped = 1; 1518 /* 1654 /* 1519 * Set up the notes in similar form t 1655 * Set up the notes in similar form to SVR4 core dumps made 1520 * with info from their /proc. 1656 * with info from their /proc. 1521 */ 1657 */ 1522 1658 >> 1659 fill_note(notes + 0, "CORE", NT_PRSTATUS, sizeof(*prstatus), prstatus); 1523 fill_psinfo(psinfo, current->group_le 1660 fill_psinfo(psinfo, current->group_leader, current->mm); 1524 fill_note(&psinfo_note, "CORE", NT_PR !! 1661 fill_note(notes + 1, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); 1525 thread_status_size += notesize(&psinf !! 1662 >> 1663 numnote = 2; 1526 1664 1527 auxv = (elf_addr_t *) current->mm->sa 1665 auxv = (elf_addr_t *) current->mm->saved_auxv; >> 1666 1528 i = 0; 1667 i = 0; 1529 do 1668 do 1530 i += 2; 1669 i += 2; 1531 while (auxv[i - 2] != AT_NULL); 1670 while (auxv[i - 2] != AT_NULL); 1532 fill_note(&auxv_note, "CORE", NT_AUXV !! 1671 fill_note(¬es[numnote++], "CORE", NT_AUXV, 1533 thread_status_size += notesize(&auxv_ !! 1672 i * sizeof(elf_addr_t), auxv); 1534 1673 1535 offset = sizeof(*elf); !! 1674 /* Try to dump the FPU. */ >> 1675 if ((prstatus->pr_fpvalid = >> 1676 elf_core_copy_task_fpregs(current, cprm->regs, fpu))) >> 1677 fill_note(notes + numnote++, >> 1678 "CORE", NT_PRFPREG, sizeof(*fpu), fpu); >> 1679 #ifdef ELF_CORE_COPY_XFPREGS >> 1680 if (elf_core_copy_task_xfpregs(current, xfpu)) >> 1681 fill_note(notes + numnote++, >> 1682 "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu); >> 1683 #endif >> 1684 >> 1685 fs = get_fs(); >> 1686 set_fs(KERNEL_DS); >> 1687 >> 1688 offset += sizeof(*elf); /* Elf header */ 1536 offset += segs * sizeof(struct elf_ph 1689 offset += segs * sizeof(struct elf_phdr); /* Program headers */ 1537 1690 1538 /* Write notes phdr entry */ 1691 /* Write notes phdr entry */ 1539 phdr4note = kmalloc(sizeof(*phdr4note !! 1692 { 1540 if (!phdr4note) !! 1693 int sz = 0; 1541 goto end_coredump; !! 1694 >> 1695 for (i = 0; i < numnote; i++) >> 1696 sz += notesize(notes + i); >> 1697 >> 1698 sz += thread_status_size; >> 1699 >> 1700 phdr4note = kmalloc(sizeof(*phdr4note), GFP_KERNEL); >> 1701 if (!phdr4note) >> 1702 goto end_coredump; 1542 1703 1543 fill_elf_note_phdr(phdr4note, thread_ !! 1704 fill_elf_note_phdr(phdr4note, sz, offset); 1544 offset += thread_status_size; !! 1705 offset += sz; >> 1706 } 1545 1707 1546 /* Page-align dumped data */ 1708 /* Page-align dumped data */ 1547 dataoff = offset = roundup(offset, EL 1709 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); 1548 1710 1549 offset += cprm->vma_data_size; !! 1711 offset += elf_core_vma_data_size(cprm->mm_flags); 1550 offset += elf_core_extra_data_size(cp !! 1712 offset += elf_core_extra_data_size(); 1551 e_shoff = offset; 1713 e_shoff = offset; 1552 1714 1553 if (e_phnum == PN_XNUM) { 1715 if (e_phnum == PN_XNUM) { 1554 shdr4extnum = kmalloc(sizeof( 1716 shdr4extnum = kmalloc(sizeof(*shdr4extnum), GFP_KERNEL); 1555 if (!shdr4extnum) 1717 if (!shdr4extnum) 1556 goto end_coredump; 1718 goto end_coredump; 1557 fill_extnum_info(elf, shdr4ex 1719 fill_extnum_info(elf, shdr4extnum, e_shoff, segs); 1558 } 1720 } 1559 1721 1560 offset = dataoff; 1722 offset = dataoff; 1561 1723 1562 if (!dump_emit(cprm, elf, sizeof(*elf 1724 if (!dump_emit(cprm, elf, sizeof(*elf))) 1563 goto end_coredump; 1725 goto end_coredump; 1564 1726 1565 if (!dump_emit(cprm, phdr4note, sizeo 1727 if (!dump_emit(cprm, phdr4note, sizeof(*phdr4note))) 1566 goto end_coredump; 1728 goto end_coredump; 1567 1729 1568 /* write program headers for segments 1730 /* write program headers for segments dump */ 1569 for (i = 0; i < cprm->vma_count; i++) !! 1731 for (vma = current->mm->mmap; vma; vma = vma->vm_next) { 1570 struct core_vma_metadata *met << 1571 struct elf_phdr phdr; 1732 struct elf_phdr phdr; 1572 size_t sz; 1733 size_t sz; 1573 1734 1574 sz = meta->end - meta->start; !! 1735 sz = vma->vm_end - vma->vm_start; 1575 1736 1576 phdr.p_type = PT_LOAD; 1737 phdr.p_type = PT_LOAD; 1577 phdr.p_offset = offset; 1738 phdr.p_offset = offset; 1578 phdr.p_vaddr = meta->start; !! 1739 phdr.p_vaddr = vma->vm_start; 1579 phdr.p_paddr = 0; 1740 phdr.p_paddr = 0; 1580 phdr.p_filesz = meta->dump_si !! 1741 phdr.p_filesz = maydump(vma, cprm->mm_flags) ? sz : 0; 1581 phdr.p_memsz = sz; 1742 phdr.p_memsz = sz; 1582 offset += phdr.p_filesz; 1743 offset += phdr.p_filesz; 1583 phdr.p_flags = 0; !! 1744 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0; 1584 if (meta->flags & VM_READ) !! 1745 if (vma->vm_flags & VM_WRITE) 1585 phdr.p_flags |= PF_R; << 1586 if (meta->flags & VM_WRITE) << 1587 phdr.p_flags |= PF_W; 1746 phdr.p_flags |= PF_W; 1588 if (meta->flags & VM_EXEC) !! 1747 if (vma->vm_flags & VM_EXEC) 1589 phdr.p_flags |= PF_X; 1748 phdr.p_flags |= PF_X; 1590 phdr.p_align = ELF_EXEC_PAGES 1749 phdr.p_align = ELF_EXEC_PAGESIZE; 1591 1750 1592 if (!dump_emit(cprm, &phdr, s 1751 if (!dump_emit(cprm, &phdr, sizeof(phdr))) 1593 goto end_coredump; 1752 goto end_coredump; 1594 } 1753 } 1595 1754 1596 if (!elf_core_write_extra_phdrs(cprm, 1755 if (!elf_core_write_extra_phdrs(cprm, offset)) 1597 goto end_coredump; 1756 goto end_coredump; 1598 1757 1599 /* write out the notes section */ !! 1758 /* write out the notes section */ 1600 if (!writenote(thread_list->notes, cp !! 1759 for (i = 0; i < numnote; i++) 1601 goto end_coredump; !! 1760 if (!writenote(notes + i, cprm)) 1602 if (!writenote(&psinfo_note, cprm)) << 1603 goto end_coredump; << 1604 if (!writenote(&auxv_note, cprm)) << 1605 goto end_coredump; << 1606 for (i = 1; i < thread_list->num_note << 1607 if (!writenote(thread_list->n << 1608 goto end_coredump; 1761 goto end_coredump; 1609 1762 1610 /* write out the thread status notes 1763 /* write out the thread status notes section */ 1611 for (tmp = thread_list->next; tmp; tm !! 1764 list_for_each(t, &thread_list) { >> 1765 struct elf_thread_status *tmp = >> 1766 list_entry(t, struct elf_thread_status, list); >> 1767 1612 for (i = 0; i < tmp->num_note 1768 for (i = 0; i < tmp->num_notes; i++) 1613 if (!writenote(&tmp-> 1769 if (!writenote(&tmp->notes[i], cprm)) 1614 goto end_core 1770 goto end_coredump; 1615 } 1771 } 1616 1772 1617 dump_skip_to(cprm, dataoff); !! 1773 if (!dump_skip(cprm, dataoff - cprm->pos)) >> 1774 goto end_coredump; 1618 1775 1619 if (!elf_fdpic_dump_segments(cprm, cp !! 1776 if (!elf_fdpic_dump_segments(cprm)) 1620 goto end_coredump; 1777 goto end_coredump; 1621 1778 1622 if (!elf_core_write_extra_data(cprm)) 1779 if (!elf_core_write_extra_data(cprm)) 1623 goto end_coredump; 1780 goto end_coredump; 1624 1781 1625 if (e_phnum == PN_XNUM) { 1782 if (e_phnum == PN_XNUM) { 1626 if (!dump_emit(cprm, shdr4ext 1783 if (!dump_emit(cprm, shdr4extnum, sizeof(*shdr4extnum))) 1627 goto end_coredump; 1784 goto end_coredump; 1628 } 1785 } 1629 1786 1630 if (cprm->file->f_pos != offset) { 1787 if (cprm->file->f_pos != offset) { 1631 /* Sanity check */ 1788 /* Sanity check */ 1632 printk(KERN_WARNING 1789 printk(KERN_WARNING 1633 "elf_core_dump: file-> 1790 "elf_core_dump: file->f_pos (%lld) != offset (%lld)\n", 1634 cprm->file->f_pos, off 1791 cprm->file->f_pos, offset); 1635 } 1792 } 1636 1793 1637 end_coredump: 1794 end_coredump: 1638 while (thread_list) { !! 1795 set_fs(fs); 1639 tmp = thread_list; !! 1796 1640 thread_list = thread_list->ne !! 1797 cleanup: 1641 kfree(tmp); !! 1798 while (!list_empty(&thread_list)) { >> 1799 struct list_head *tmp = thread_list.next; >> 1800 list_del(tmp); >> 1801 kfree(list_entry(tmp, struct elf_thread_status, list)); 1642 } 1802 } 1643 kfree(phdr4note); 1803 kfree(phdr4note); 1644 kfree(elf); 1804 kfree(elf); >> 1805 kfree(prstatus); 1645 kfree(psinfo); 1806 kfree(psinfo); >> 1807 kfree(notes); >> 1808 kfree(fpu); 1646 kfree(shdr4extnum); 1809 kfree(shdr4extnum); >> 1810 #ifdef ELF_CORE_COPY_XFPREGS >> 1811 kfree(xfpu); >> 1812 #endif 1647 return has_dumped; 1813 return has_dumped; >> 1814 #undef NUM_NOTES 1648 } 1815 } 1649 1816 1650 #endif /* CONFIG_ELF_CORE */ 1817 #endif /* CONFIG_ELF_CORE */ 1651 1818
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.