Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186316
b: refs/heads/master
c: 93eb211
h: refs/heads/master
v: v3
  • Loading branch information
Daisuke HATAYAMA authored and Linus Torvalds committed Mar 6, 2010
1 parent f2de324 commit 703440c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1fcccbac89f5bbc5e41aa72086960059fce372da
refs/heads/master: 93eb211e6c9ff6054fcf9c5b9e344d8d9ad29175
27 changes: 16 additions & 11 deletions trunk/fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ static int elf_core_dump(struct coredump_params *cprm)
loff_t offset = 0, dataoff, foffset;
unsigned long mm_flags;
struct elf_note_info info;
struct elf_phdr *phdr4note = NULL;

/*
* We no longer stop all VM operations.
Expand Down Expand Up @@ -1898,28 +1899,22 @@ static int elf_core_dump(struct coredump_params *cprm)
fs = get_fs();
set_fs(KERNEL_DS);

size += sizeof(*elf);
if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
goto end_coredump;

offset += sizeof(*elf); /* Elf header */
offset += (segs + 1) * sizeof(struct elf_phdr); /* Program headers */
foffset = offset;

/* Write notes phdr entry */
{
struct elf_phdr phdr;
size_t sz = get_note_info_size(&info);

sz += elf_coredump_extra_notes_size();

fill_elf_note_phdr(&phdr, sz, offset);
offset += sz;

size += sizeof(phdr);
if (size > cprm->limit
|| !dump_write(cprm->file, &phdr, sizeof(phdr)))
phdr4note = kmalloc(sizeof(*phdr4note), GFP_KERNEL);
if (!phdr4note)
goto end_coredump;

fill_elf_note_phdr(phdr4note, sz, offset);
offset += sz;
}

dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
Expand All @@ -1931,6 +1926,15 @@ static int elf_core_dump(struct coredump_params *cprm)
*/
mm_flags = current->mm->flags;

size += sizeof(*elf);
if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
goto end_coredump;

size += sizeof(*phdr4note);
if (size > cprm->limit
|| !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
goto end_coredump;

/* Write program headers for segments dump */
for (vma = first_vma(current, gate_vma); vma != NULL;
vma = next_vma(vma, gate_vma)) {
Expand Down Expand Up @@ -2004,6 +2008,7 @@ static int elf_core_dump(struct coredump_params *cprm)

cleanup:
free_note_info(&info);
kfree(phdr4note);
kfree(elf);
out:
return has_dumped;
Expand Down
29 changes: 16 additions & 13 deletions trunk/fs/binfmt_elf_fdpic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
int thread_status_size = 0;
elf_addr_t *auxv;
unsigned long mm_flags;
struct elf_phdr *phdr4note = NULL;

/*
* We no longer stop all VM operations.
Expand Down Expand Up @@ -1706,32 +1707,25 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
fs = get_fs();
set_fs(KERNEL_DS);

size += sizeof(*elf);
if (size > cprm->limit
|| !dump_write(cprm->file, elf, sizeof(*elf)))
goto end_coredump;

offset += sizeof(*elf); /* Elf header */
offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers */
foffset = offset;

/* Write notes phdr entry */
{
struct elf_phdr phdr;
int sz = 0;

for (i = 0; i < numnote; i++)
sz += notesize(notes + i);

sz += thread_status_size;

fill_elf_note_phdr(&phdr, sz, offset);
offset += sz;

size += sizeof(phdr);
if (size > cprm->limit
|| !dump_write(cprm->file, &phdr, sizeof(phdr)))
phdr4note = kmalloc(sizeof(*phdr4note), GFP_KERNEL);
if (!phdr4note)
goto end_coredump;

fill_elf_note_phdr(phdr4note, sz, offset);
offset += sz;
}

/* Page-align dumped data */
Expand All @@ -1744,6 +1738,15 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
*/
mm_flags = current->mm->flags;

size += sizeof(*elf);
if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
goto end_coredump;

size += sizeof(*phdr4note);
if (size > cprm->limit
|| !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
goto end_coredump;

/* write program headers for segments dump */
for (vma = current->mm->mmap; vma; vma = vma->vm_next) {
struct elf_phdr phdr;
Expand Down Expand Up @@ -1815,7 +1818,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
list_del(tmp);
kfree(list_entry(tmp, struct elf_thread_status, list));
}

kfree(phdr4note);
kfree(elf);
kfree(prstatus);
kfree(psinfo);
Expand Down

0 comments on commit 703440c

Please sign in to comment.