Commit 38cdabb7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

binfmt_elf_fdpic: remove the set_fs(KERNEL_DS) in elf_fdpic_core_dump

There is no logic in elf_fdpic_core_dump itself or in the various arch
helpers called from it which use uaccess routines on kernel pointers
except for the file writes thate are nicely encapsulated by using
__kernel_write in dump_emit.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent d2530b43
...@@ -1549,7 +1549,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1549,7 +1549,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
{ {
#define NUM_NOTES 6 #define NUM_NOTES 6
int has_dumped = 0; int has_dumped = 0;
mm_segment_t fs;
int segs; int segs;
int i; int i;
struct vm_area_struct *vma; struct vm_area_struct *vma;
...@@ -1589,31 +1588,31 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1589,31 +1588,31 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
/* alloc memory for large data structures: too large to be on stack */ /* alloc memory for large data structures: too large to be on stack */
elf = kmalloc(sizeof(*elf), GFP_KERNEL); elf = kmalloc(sizeof(*elf), GFP_KERNEL);
if (!elf) if (!elf)
goto cleanup; goto end_coredump;
prstatus = kzalloc(sizeof(*prstatus), GFP_KERNEL); prstatus = kzalloc(sizeof(*prstatus), GFP_KERNEL);
if (!prstatus) if (!prstatus)
goto cleanup; goto end_coredump;
psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
if (!psinfo) if (!psinfo)
goto cleanup; goto end_coredump;
notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote), notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote),
GFP_KERNEL); GFP_KERNEL);
if (!notes) if (!notes)
goto cleanup; goto end_coredump;
fpu = kmalloc(sizeof(*fpu), GFP_KERNEL); fpu = kmalloc(sizeof(*fpu), GFP_KERNEL);
if (!fpu) if (!fpu)
goto cleanup; goto end_coredump;
#ifdef ELF_CORE_COPY_XFPREGS #ifdef ELF_CORE_COPY_XFPREGS
xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL); xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL);
if (!xfpu) if (!xfpu)
goto cleanup; goto end_coredump;
#endif #endif
for (ct = current->mm->core_state->dumper.next; for (ct = current->mm->core_state->dumper.next;
ct; ct = ct->next) { ct; ct = ct->next) {
tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
if (!tmp) if (!tmp)
goto cleanup; goto end_coredump;
tmp->thread = ct->task; tmp->thread = ct->task;
list_add(&tmp->list, &thread_list); list_add(&tmp->list, &thread_list);
...@@ -1678,9 +1677,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1678,9 +1677,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
"LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu); "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
#endif #endif
fs = get_fs();
set_fs(KERNEL_DS);
offset += sizeof(*elf); /* Elf header */ offset += sizeof(*elf); /* Elf header */
offset += segs * sizeof(struct elf_phdr); /* Program headers */ offset += segs * sizeof(struct elf_phdr); /* Program headers */
...@@ -1788,9 +1784,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1788,9 +1784,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
} }
end_coredump: end_coredump:
set_fs(fs);
cleanup:
while (!list_empty(&thread_list)) { while (!list_empty(&thread_list)) {
struct list_head *tmp = thread_list.next; struct list_head *tmp = thread_list.next;
list_del(tmp); list_del(tmp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment