[PATCH] fix elf_core_dump bug when writing xfpregs and not fpregs

From: Roland McGrath (roland@redhat.com)
Date: Wed May 14 2003 - 20:04:34 EST


For some reason an ia32-mode core dump on amd64 for me wanted to include
the NT_PRXFPREG note but not the NT_PRFPREG note. elf_core_dump is buggy
in this case and will try to use an initialized structure later on (notes[3]).

The patch vs 2.5.69 plus the cset-1.1042.114.10-to-1.1117.txt patch fixes it.

Thanks,
Roland

--- linux-2.5.69-1.1117/fs/binfmt_elf.c.~1~ Wed May 14 17:59:07 2003
+++ linux-2.5.69-1.1117/fs/binfmt_elf.c Wed May 14 18:00:47 2003
@@ -1191,7 +1191,7 @@ static int elf_core_dump(long signr, str
         struct elfhdr *elf = NULL;
         off_t offset = 0, dataoff;
         unsigned long limit = current->rlim[RLIMIT_CORE].rlim_cur;
- int numnote = NUM_NOTES;
+ int numnote;
         struct memelfnote *notes = NULL;
         struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */
         struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */
@@ -1282,18 +1282,16 @@ static int elf_core_dump(long signr, str
         
         fill_note(notes +2, "CORE", NT_TASKSTRUCT, sizeof(*current), current);
   
+ numnote = 3;
+
           /* Try to dump the FPU. */
         if ((prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, fpu)))
- fill_note(notes +3, "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
- else
- --numnote;
+ fill_note(notes + numnote++,
+ "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
 #ifdef ELF_CORE_COPY_XFPREGS
         if (elf_core_copy_task_xfpregs(current, xfpu))
- fill_note(notes +4, "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
- else
- --numnote;
-#else
- numnote--;
+ fill_note(notes + numnote++,
+ "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
 #endif
   
         fs = get_fs();
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu May 15 2003 - 22:00:54 EST