diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 9924581df6f6..b25707fee2cc 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1255,26 +1255,23 @@ static int writenote(struct memelfnote *men, struct file *file, | |||
1255 | static void fill_elf_header(struct elfhdr *elf, int segs, | 1255 | static void fill_elf_header(struct elfhdr *elf, int segs, |
1256 | u16 machine, u32 flags, u8 osabi) | 1256 | u16 machine, u32 flags, u8 osabi) |
1257 | { | 1257 | { |
1258 | memset(elf, 0, sizeof(*elf)); | ||
1259 | |||
1258 | memcpy(elf->e_ident, ELFMAG, SELFMAG); | 1260 | memcpy(elf->e_ident, ELFMAG, SELFMAG); |
1259 | elf->e_ident[EI_CLASS] = ELF_CLASS; | 1261 | elf->e_ident[EI_CLASS] = ELF_CLASS; |
1260 | elf->e_ident[EI_DATA] = ELF_DATA; | 1262 | elf->e_ident[EI_DATA] = ELF_DATA; |
1261 | elf->e_ident[EI_VERSION] = EV_CURRENT; | 1263 | elf->e_ident[EI_VERSION] = EV_CURRENT; |
1262 | elf->e_ident[EI_OSABI] = ELF_OSABI; | 1264 | elf->e_ident[EI_OSABI] = ELF_OSABI; |
1263 | memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD); | ||
1264 | 1265 | ||
1265 | elf->e_type = ET_CORE; | 1266 | elf->e_type = ET_CORE; |
1266 | elf->e_machine = machine; | 1267 | elf->e_machine = machine; |
1267 | elf->e_version = EV_CURRENT; | 1268 | elf->e_version = EV_CURRENT; |
1268 | elf->e_entry = 0; | ||
1269 | elf->e_phoff = sizeof(struct elfhdr); | 1269 | elf->e_phoff = sizeof(struct elfhdr); |
1270 | elf->e_shoff = 0; | ||
1271 | elf->e_flags = flags; | 1270 | elf->e_flags = flags; |
1272 | elf->e_ehsize = sizeof(struct elfhdr); | 1271 | elf->e_ehsize = sizeof(struct elfhdr); |
1273 | elf->e_phentsize = sizeof(struct elf_phdr); | 1272 | elf->e_phentsize = sizeof(struct elf_phdr); |
1274 | elf->e_phnum = segs; | 1273 | elf->e_phnum = segs; |
1275 | elf->e_shentsize = 0; | 1274 | |
1276 | elf->e_shnum = 0; | ||
1277 | elf->e_shstrndx = 0; | ||
1278 | return; | 1275 | return; |
1279 | } | 1276 | } |
1280 | 1277 | ||
@@ -1725,26 +1722,25 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, | |||
1725 | 1722 | ||
1726 | info->thread_status_size = 0; | 1723 | info->thread_status_size = 0; |
1727 | if (signr) { | 1724 | if (signr) { |
1728 | struct elf_thread_status *tmp; | 1725 | struct elf_thread_status *ets; |
1729 | rcu_read_lock(); | 1726 | rcu_read_lock(); |
1730 | do_each_thread(g, p) | 1727 | do_each_thread(g, p) |
1731 | if (current->mm == p->mm && current != p) { | 1728 | if (current->mm == p->mm && current != p) { |
1732 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); | 1729 | ets = kzalloc(sizeof(*ets), GFP_ATOMIC); |
1733 | if (!tmp) { | 1730 | if (!ets) { |
1734 | rcu_read_unlock(); | 1731 | rcu_read_unlock(); |
1735 | return 0; | 1732 | return 0; |
1736 | } | 1733 | } |
1737 | tmp->thread = p; | 1734 | ets->thread = p; |
1738 | list_add(&tmp->list, &info->thread_list); | 1735 | list_add(&ets->list, &info->thread_list); |
1739 | } | 1736 | } |
1740 | while_each_thread(g, p); | 1737 | while_each_thread(g, p); |
1741 | rcu_read_unlock(); | 1738 | rcu_read_unlock(); |
1742 | list_for_each(t, &info->thread_list) { | 1739 | list_for_each(t, &info->thread_list) { |
1743 | struct elf_thread_status *tmp; | ||
1744 | int sz; | 1740 | int sz; |
1745 | 1741 | ||
1746 | tmp = list_entry(t, struct elf_thread_status, list); | 1742 | ets = list_entry(t, struct elf_thread_status, list); |
1747 | sz = elf_dump_thread_status(signr, tmp); | 1743 | sz = elf_dump_thread_status(signr, ets); |
1748 | info->thread_status_size += sz; | 1744 | info->thread_status_size += sz; |
1749 | } | 1745 | } |
1750 | } | 1746 | } |
@@ -2000,10 +1996,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
2000 | 1996 | ||
2001 | for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) { | 1997 | for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) { |
2002 | struct page *page; | 1998 | struct page *page; |
2003 | struct vm_area_struct *vma; | 1999 | struct vm_area_struct *tmp_vma; |
2004 | 2000 | ||
2005 | if (get_user_pages(current, current->mm, addr, 1, 0, 1, | 2001 | if (get_user_pages(current, current->mm, addr, 1, 0, 1, |
2006 | &page, &vma) <= 0) { | 2002 | &page, &tmp_vma) <= 0) { |
2007 | DUMP_SEEK(PAGE_SIZE); | 2003 | DUMP_SEEK(PAGE_SIZE); |
2008 | } else { | 2004 | } else { |
2009 | if (page == ZERO_PAGE(0)) { | 2005 | if (page == ZERO_PAGE(0)) { |
@@ -2013,7 +2009,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
2013 | } | 2009 | } |
2014 | } else { | 2010 | } else { |
2015 | void *kaddr; | 2011 | void *kaddr; |
2016 | flush_cache_page(vma, addr, | 2012 | flush_cache_page(tmp_vma, addr, |
2017 | page_to_pfn(page)); | 2013 | page_to_pfn(page)); |
2018 | kaddr = kmap(page); | 2014 | kaddr = kmap(page); |
2019 | if ((size += PAGE_SIZE) > limit || | 2015 | if ((size += PAGE_SIZE) > limit || |