Skip to content

Commit 38cdabb

Browse files
Christoph HellwigAl Viro
authored andcommitted
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: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent d2530b4 commit 38cdabb

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

fs/binfmt_elf_fdpic.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15491549
{
15501550
#define NUM_NOTES 6
15511551
int has_dumped = 0;
1552-
mm_segment_t fs;
15531552
int segs;
15541553
int i;
15551554
struct vm_area_struct *vma;
@@ -1589,31 +1588,31 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15891588
/* alloc memory for large data structures: too large to be on stack */
15901589
elf = kmalloc(sizeof(*elf), GFP_KERNEL);
15911590
if (!elf)
1592-
goto cleanup;
1591+
goto end_coredump;
15931592
prstatus = kzalloc(sizeof(*prstatus), GFP_KERNEL);
15941593
if (!prstatus)
1595-
goto cleanup;
1594+
goto end_coredump;
15961595
psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
15971596
if (!psinfo)
1598-
goto cleanup;
1597+
goto end_coredump;
15991598
notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote),
16001599
GFP_KERNEL);
16011600
if (!notes)
1602-
goto cleanup;
1601+
goto end_coredump;
16031602
fpu = kmalloc(sizeof(*fpu), GFP_KERNEL);
16041603
if (!fpu)
1605-
goto cleanup;
1604+
goto end_coredump;
16061605
#ifdef ELF_CORE_COPY_XFPREGS
16071606
xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL);
16081607
if (!xfpu)
1609-
goto cleanup;
1608+
goto end_coredump;
16101609
#endif
16111610

16121611
for (ct = current->mm->core_state->dumper.next;
16131612
ct; ct = ct->next) {
16141613
tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
16151614
if (!tmp)
1616-
goto cleanup;
1615+
goto end_coredump;
16171616

16181617
tmp->thread = ct->task;
16191618
list_add(&tmp->list, &thread_list);
@@ -1678,9 +1677,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
16781677
"LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
16791678
#endif
16801679

1681-
fs = get_fs();
1682-
set_fs(KERNEL_DS);
1683-
16841680
offset += sizeof(*elf); /* Elf header */
16851681
offset += segs * sizeof(struct elf_phdr); /* Program headers */
16861682

@@ -1788,9 +1784,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
17881784
}
17891785

17901786
end_coredump:
1791-
set_fs(fs);
1792-
1793-
cleanup:
17941787
while (!list_empty(&thread_list)) {
17951788
struct list_head *tmp = thread_list.next;
17961789
list_del(tmp);

0 commit comments

Comments
 (0)