Revert "coredump: Use the vma snapshot in fill_files_note"

This reverts commit 558564db44.

It breaks the abi and is not needed for Android devices so it can be
dropped.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I439e74ddf123b2e4d573f490b3c5ba16a08f2d9b
This commit is contained in:
Greg Kroah-Hartman
2022-04-19 18:41:13 +02:00
parent c4eb663fca
commit 5f24894332
3 changed files with 13 additions and 35 deletions

View File

@@ -1613,16 +1613,17 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
* long file_ofs * long file_ofs
* followed by COUNT filenames in ASCII: "FILE1" NUL "FILE2" NUL... * followed by COUNT filenames in ASCII: "FILE1" NUL "FILE2" NUL...
*/ */
static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm) static int fill_files_note(struct memelfnote *note)
{ {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
unsigned count, size, names_ofs, remaining, n; unsigned count, size, names_ofs, remaining, n;
user_long_t *data; user_long_t *data;
user_long_t *start_end_ofs; user_long_t *start_end_ofs;
char *name_base, *name_curpos; char *name_base, *name_curpos;
int i;
/* *Estimated* file count and total data size needed */ /* *Estimated* file count and total data size needed */
count = cprm->vma_count; count = mm->map_count;
if (count > UINT_MAX / 64) if (count > UINT_MAX / 64)
return -EINVAL; return -EINVAL;
size = count * 64; size = count * 64;
@@ -1644,12 +1645,11 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
name_base = name_curpos = ((char *)data) + names_ofs; name_base = name_curpos = ((char *)data) + names_ofs;
remaining = size - names_ofs; remaining = size - names_ofs;
count = 0; count = 0;
for (i = 0; i < cprm->vma_count; i++) { for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
struct core_vma_metadata *m = &cprm->vma_meta[i];
struct file *file; struct file *file;
const char *filename; const char *filename;
file = m->file; file = vma->vm_file;
if (!file) if (!file)
continue; continue;
filename = file_path(file, name_curpos, remaining); filename = file_path(file, name_curpos, remaining);
@@ -1669,9 +1669,9 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
memmove(name_curpos, filename, n); memmove(name_curpos, filename, n);
name_curpos += n; name_curpos += n;
*start_end_ofs++ = m->start; *start_end_ofs++ = vma->vm_start;
*start_end_ofs++ = m->end; *start_end_ofs++ = vma->vm_end;
*start_end_ofs++ = m->pgoff; *start_end_ofs++ = vma->vm_pgoff;
count++; count++;
} }
@@ -1682,7 +1682,7 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
* Count usually is less than mm->map_count, * Count usually is less than mm->map_count,
* we need to move filenames down. * we need to move filenames down.
*/ */
n = cprm->vma_count - count; n = mm->map_count - count;
if (n != 0) { if (n != 0) {
unsigned shift_bytes = n * 3 * sizeof(data[0]); unsigned shift_bytes = n * 3 * sizeof(data[0]);
memmove(name_base - shift_bytes, name_base, memmove(name_base - shift_bytes, name_base,
@@ -1884,7 +1884,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
fill_auxv_note(&info->auxv, current->mm); fill_auxv_note(&info->auxv, current->mm);
info->size += notesize(&info->auxv); info->size += notesize(&info->auxv);
if (fill_files_note(&info->files, cprm) == 0) if (fill_files_note(&info->files) == 0)
info->size += notesize(&info->files); info->size += notesize(&info->files);
return 1; return 1;
@@ -2073,7 +2073,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
fill_auxv_note(info->notes + 3, current->mm); fill_auxv_note(info->notes + 3, current->mm);
info->numnote = 4; info->numnote = 4;
if (fill_files_note(info->notes + info->numnote, cprm) == 0) { if (fill_files_note(info->notes + info->numnote) == 0) {
info->notes_files = info->notes + info->numnote; info->notes_files = info->notes + info->numnote;
info->numnote++; info->numnote++;
} }

View File

@@ -54,7 +54,6 @@
#include <trace/events/sched.h> #include <trace/events/sched.h>
static bool dump_vma_snapshot(struct coredump_params *cprm); static bool dump_vma_snapshot(struct coredump_params *cprm);
static void free_vma_snapshot(struct coredump_params *cprm);
int core_uses_pid; int core_uses_pid;
unsigned int core_pipe_limit; unsigned int core_pipe_limit;
@@ -817,7 +816,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
file_start_write(cprm.file); file_start_write(cprm.file);
core_dumped = binfmt->core_dump(&cprm); core_dumped = binfmt->core_dump(&cprm);
file_end_write(cprm.file); file_end_write(cprm.file);
free_vma_snapshot(&cprm); kvfree(cprm.vma_meta);
} }
if (ispipe && core_pipe_limit) if (ispipe && core_pipe_limit)
wait_for_dump_helpers(cprm.file); wait_for_dump_helpers(cprm.file);
@@ -1089,20 +1088,6 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma,
return gate_vma; return gate_vma;
} }
static void free_vma_snapshot(struct coredump_params *cprm)
{
if (cprm->vma_meta) {
int i;
for (i = 0; i < cprm->vma_count; i++) {
struct file *file = cprm->vma_meta[i].file;
if (file)
fput(file);
}
kvfree(cprm->vma_meta);
cprm->vma_meta = NULL;
}
}
/* /*
* Under the mmap_lock, take a snapshot of relevant information about the task's * Under the mmap_lock, take a snapshot of relevant information about the task's
* VMAs. * VMAs.
@@ -1139,11 +1124,6 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
m->end = vma->vm_end; m->end = vma->vm_end;
m->flags = vma->vm_flags; m->flags = vma->vm_flags;
m->dump_size = vma_dump_size(vma, cprm->mm_flags); m->dump_size = vma_dump_size(vma, cprm->mm_flags);
m->pgoff = vma->vm_pgoff;
m->file = vma->vm_file;
if (m->file)
get_file(m->file);
} }
mmap_write_unlock(mm); mmap_write_unlock(mm);

View File

@@ -11,8 +11,6 @@ struct core_vma_metadata {
unsigned long start, end; unsigned long start, end;
unsigned long flags; unsigned long flags;
unsigned long dump_size; unsigned long dump_size;
unsigned long pgoff;
struct file *file;
}; };
/* /*