Skip to content

Commit d2530b4

Browse files
Christoph HellwigAl Viro
authored andcommitted
binfmt_elf: remove the set_fs(KERNEL_DS) in elf_core_dump
There is no logic in elf_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 fa4751f commit d2530b4

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

fs/binfmt_elf.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,6 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
13551355
vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) {
13561356
u32 __user *header = (u32 __user *) vma->vm_start;
13571357
u32 word;
1358-
mm_segment_t fs = get_fs();
13591358
/*
13601359
* Doing it this way gets the constant folded by GCC.
13611360
*/
@@ -1368,14 +1367,8 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
13681367
magic.elfmag[EI_MAG1] = ELFMAG1;
13691368
magic.elfmag[EI_MAG2] = ELFMAG2;
13701369
magic.elfmag[EI_MAG3] = ELFMAG3;
1371-
/*
1372-
* Switch to the user "segment" for get_user(),
1373-
* then put back what elf_core_dump() had in place.
1374-
*/
1375-
set_fs(USER_DS);
13761370
if (unlikely(get_user(word, header)))
13771371
word = 0;
1378-
set_fs(fs);
13791372
if (word == magic.cmp)
13801373
return PAGE_SIZE;
13811374
}
@@ -2183,7 +2176,6 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
21832176
static int elf_core_dump(struct coredump_params *cprm)
21842177
{
21852178
int has_dumped = 0;
2186-
mm_segment_t fs;
21872179
int segs, i;
21882180
size_t vma_data_size = 0;
21892181
struct vm_area_struct *vma, *gate_vma;
@@ -2232,13 +2224,10 @@ static int elf_core_dump(struct coredump_params *cprm)
22322224
* notes. This also sets up the file header.
22332225
*/
22342226
if (!fill_note_info(&elf, e_phnum, &info, cprm->siginfo, cprm->regs))
2235-
goto cleanup;
2227+
goto end_coredump;
22362228

22372229
has_dumped = 1;
22382230

2239-
fs = get_fs();
2240-
set_fs(KERNEL_DS);
2241-
22422231
offset += sizeof(elf); /* Elf header */
22432232
offset += segs * sizeof(struct elf_phdr); /* Program headers */
22442233

@@ -2366,9 +2355,6 @@ static int elf_core_dump(struct coredump_params *cprm)
23662355
}
23672356

23682357
end_coredump:
2369-
set_fs(fs);
2370-
2371-
cleanup:
23722358
free_note_info(&info);
23732359
kfree(shdr4extnum);
23742360
kvfree(vma_filesz);

0 commit comments

Comments
 (0)