]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user/elfload: Lock cpu list and mmap during elf_core_dump
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 27 Feb 2024 03:14:22 +0000 (17:14 -1000)
committerRichard Henderson <richard.henderson@linaro.org>
Thu, 29 Feb 2024 18:48:02 +0000 (08:48 -1000)
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>
linux-user/elfload.c

index 16dd08a828ff94bbb3d33bcce4b17afaca31c8a7..6f9da721d74f676119208ac372bad4bf3ec2d718 100644 (file)
@@ -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));
     }
 }
 
@@ -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
@@ -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);