Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 2911

kernel-2.6.18-194.11.1.el5.src.rpm

From: AMEET M. PARANJAPE <aparanja@redhat.com>
Date: Fri, 31 Oct 2008 15:28:36 -0400
Subject: [ppc64] cell: corrupt SPU coredump notes
Message-id: 20081031192807.21453.26744.sendpatchset@squad5-lp1.lab.bos.redhat.com
O-Subject: [PATCH RHEL5.3 BZ431881] Kernel generates corrupt Cell SPU coredump notes
Bugzilla: 431881
RH-Acked-by: David Howells <dhowells@redhat.com>

RHBZ#:
======
https://bugzilla.redhat.com/show_bug.cgi?id=431881

Description:
===========
Currently, the file offset pointer given to
elf_coredump_extra_notes_write() is file->f_pos - with recent changes
(in -111), the generic coredump code has been changed to use a
separate foffset variable, to allow coredumps to files with no
f_pos semantics (eg, pipes).

This breaks the cell coredump code, which has been changed to update
file->f_pos, not the foffset pointer. This results in the coredump
being malformed - the SPU notes section extends beyond the size
specified in the ELF header for the coredump.

This change brings the change to elf_coredump_extra_notes_write
into line with the call to writenote. Because we now use the
foffset var separately, we need to change spufs_dump_write to
update this offset.

RHEL Version Found:
================
RHEL 5.3 alpha

kABI Status:
============
No symbols were harmed.

Brew:
=====
Built on all platforms.
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=1550242

Upstream Status:
================
This is not a problem in upstream kernels, which use a separate variable for
the foffset argument.

Test Status:
============
Without the attached patch, coredumps from Cell applications generated by RHEL
5.3 kernels will be corrupt, and hence unreadable by a debugger.

With this patch applied, all of the coredump tests in spufs-testsuite will now
pass.
===============================================================
Ameet Paranjape 978-392-3903 ext 23903
IBM on-site partner

Proposed Patch:
===============

diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index 8c40e27..b962c3a 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -60,6 +60,7 @@ static int spufs_dump_write(struct file *file, const void *addr, int nr, loff_t
 		return -EIO;
 
 	written = file->f_op->write(file, addr, nr, &file->f_pos);
+	*foffset += written;
 
 	if (written != nr)
 		return -EIO;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index d32a0c5..df3b48e 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1759,7 +1759,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
 		if (!writenote(notes + i, file, &foffset))
 			goto end_coredump;
 
-	if (elf_coredump_extra_notes_write(file, &file->f_pos))
+	if (elf_coredump_extra_notes_write(file, &foffset))
 		goto end_coredump;
 
 	/* write out the thread status notes section */