[parisc-linux-cvs] linux-2.5 tausq

Randolph Chung Randolph Chung <randolph@tausq.org>
Tue, 11 Mar 2003 23:18:37 -0800


> 2.5.64-pa4
> fix elf core dumping code so that it will not crash the kernel
> also small patch to fs/binfmt_elf.c to get rid of a compile warning

Index: arch/parisc/kernel/binfmt_elf32.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/parisc/kernel/binfmt_elf32.c,v
retrieving revision 1.4
diff -u -p -r1.4 binfmt_elf32.c
--- arch/parisc/kernel/binfmt_elf32.c	15 Feb 2003 03:47:04 -0000	1.4
+++ arch/parisc/kernel/binfmt_elf32.c	12 Mar 2003 07:16:19 -0000
@@ -12,6 +12,26 @@
 
 #define ELF_CLASS	ELFCLASS32
 
+#define ELF_CORE_COPY_REGS(dst, pt)	\
+	memset(dst, 0, sizeof(dst));	/* don't leak any "random" bits */ \
+	{	int i; \
+		for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \
+		for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \
+	} \
+	dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \
+	dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \
+	dst[44] = (elf_greg_t) pt->sar;   dst[45] = (elf_greg_t) pt->iir; \
+	dst[46] = (elf_greg_t) pt->isr;   dst[47] = (elf_greg_t) pt->ior; \
+	dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \
+	dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \
+	dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \
+	dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \
+	dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \
+	dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \
+	dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \
+	dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15);
+
+
 typedef unsigned int elf_greg_t;
 
 #include <linux/spinlock.h>
@@ -60,25 +80,6 @@ struct elf_prpsinfo32
 #define init_elf_binfmt init_elf32_binfmt
 
 #define ELF_PLATFORM  ("PARISC32\0")
-
-#define ELF_CORE_COPY_REGS(dst, pt)	\
-	memset(dst, 0, sizeof(dst));	/* don't leak any "random" bits */ \
-	{	int i; \
-		for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \
-		for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \
-	} \
-	dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \
-	dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \
-	dst[44] = (elf_greg_t) pt->sar;   dst[45] = (elf_greg_t) pt->iir; \
-	dst[46] = (elf_greg_t) pt->isr;   dst[47] = (elf_greg_t) pt->ior; \
-	dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \
-	dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \
-	dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \
-	dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \
-	dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \
-	dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \
-	dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \
-	dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15);
 
 /*
  * We should probably use this macro to set a flag somewhere to indicate
Index: arch/parisc/kernel/process.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/parisc/kernel/process.c,v
retrieving revision 1.13
diff -u -p -r1.13 process.c
--- arch/parisc/kernel/process.c	29 Nov 2002 16:51:24 -0000	1.13
+++ arch/parisc/kernel/process.c	12 Mar 2003 07:16:20 -0000
@@ -205,7 +205,16 @@ void release_thread(struct task_struct *
 
 int dump_fpu (struct pt_regs * regs, elf_fpregset_t *r)
 {
+	if (regs == NULL)
+		return 0;
+
 	memcpy(r, regs->fr, sizeof *r);
+	return 1;
+}
+
+int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
+{
+	memcpy(r, tsk->thread.regs.fr, sizeof(*r));
 	return 1;
 }
 
Index: fs/binfmt_elf.c
===================================================================
RCS file: /var/cvs/linux-2.5/fs/binfmt_elf.c,v
retrieving revision 1.11
diff -u -p -r1.11 binfmt_elf.c
--- fs/binfmt_elf.c	10 Feb 2003 22:24:21 -0000	1.11
+++ fs/binfmt_elf.c	12 Mar 2003 07:16:21 -0000
@@ -113,7 +113,7 @@ static void padzero(unsigned long elf_bs
 #define STACK_ADD(sp, items) ((elf_addr_t *)(sp) + (items))
 #define STACK_ROUND(sp, items) \
 	((15 + (unsigned long) ((sp) + (items))) &~ 15UL)
-#define STACK_ALLOC(sp, len) ({ elf_addr_t *old_sp = sp; sp += len; old_sp; })
+#define STACK_ALLOC(sp, len) ({ elf_addr_t *old_sp = (elf_addr_t *)sp; sp += len; old_sp; })
 #else
 #define STACK_ADD(sp, items) ((elf_addr_t *)(sp) - (items))
 #define STACK_ROUND(sp, items) \
Index: include/asm-parisc/elf.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-parisc/elf.h,v
retrieving revision 1.3
diff -u -p -r1.3 elf.h
--- include/asm-parisc/elf.h	20 Jul 2002 15:52:25 -0000	1.3
+++ include/asm-parisc/elf.h	12 Mar 2003 07:16:21 -0000
@@ -99,6 +99,9 @@ typedef elf_greg_t elf_gregset_t[ELF_NGR
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
+extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
+#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
+
 struct pt_regs;	/* forward declaration... */
 
 
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/