Skip to content

Commit

Permalink
linux-user/elfload: Lock cpu list and mmap during elf_core_dump
Browse files Browse the repository at this point in the history
Do not allow changes to the set of cpus and memory regions
while we are dumping core.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Feb 29, 2024
1 parent e0add9a commit b526207
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -4537,13 +4537,11 @@ static void fill_note_info(struct elf_note_info *info,
}

/* read and fill status of all threads */
WITH_QEMU_LOCK_GUARD(&qemu_cpu_list_lock) {
CPU_FOREACH(cpu) {
if (cpu == thread_cpu) {
continue;
}
fill_thread_info(info, cpu_env(cpu));
CPU_FOREACH(cpu) {
if (cpu == thread_cpu) {
continue;
}
fill_thread_info(info, cpu_env(cpu));
}
}

Expand Down Expand Up @@ -4643,6 +4641,9 @@ static int elf_core_dump(int signr, const CPUArchState *env)
return 0;
}

cpu_list_lock();
mmap_lock();

/*
* Walk through target process memory mappings and
* set up structure containing this information. After
Expand Down Expand Up @@ -4760,6 +4761,8 @@ static int elf_core_dump(int signr, const CPUArchState *env)

out:
ret = -errno;
mmap_unlock();
cpu_list_unlock();
free_note_info(&info);
vma_delete(&mm);
close(fd);
Expand Down

0 comments on commit b526207

Please sign in to comment.