[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.8 25/49] linux-user: Emulate /proc/self/maps under mmap_lock
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.8 25/49] linux-user: Emulate /proc/self/maps under mmap_lock |
Date: |
Sat, 9 Nov 2024 13:14:16 +0300 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
If one thread modifies the mappings and another thread prints them,
a situation may occur that the printer thread sees a guest mapping
without a corresponding host mapping, leading to a crash in
open_self_maps_2().
Cc: qemu-stable@nongnu.org
Fixes: 7b7a3366e142 ("linux-user: Use walk_memory_regions for open_self_maps")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20241014203441.387560-1-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit bbd5630a75e70a0f1bcf04de74c94aa94a145628)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: context fix in linux-user/syscall.c due to missing
v9.0.0-421-g59272469bd13
"user: Use get_task_state() helper")
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d9212aa966..e178366093 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8120,17 +8120,19 @@ static int open_self_maps_1(CPUArchState *env, int fd,
bool smaps)
{
struct open_self_maps_data d = {
.ts = env_cpu(env)->opaque,
- .host_maps = read_self_maps(),
.fd = fd,
.smaps = smaps
};
+ mmap_lock();
+ d.host_maps = read_self_maps();
if (d.host_maps) {
walk_memory_regions(&d, open_self_maps_2);
free_self_maps(d.host_maps);
} else {
walk_memory_regions(&d, open_self_maps_3);
}
+ mmap_unlock();
return 0;
}
--
2.39.5
- [Stable-8.2.8 15/49] hw/audio/hda: free timer on exit, (continued)
- [Stable-8.2.8 15/49] hw/audio/hda: free timer on exit, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 16/49] ui/win32: fix potential use-after-free with dbus shared memory, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 18/49] accel/kvm: check for KVM_CAP_READONLY_MEM on VM, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 33/49] target/arm: Don't assert in regime_is_user() for E10 mmuidx values, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 11/49] tcg/ppc: Use TCG_REG_TMP2 for scratch tcg_out_qemu_st, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 26/49] linux-user/ppc: Fix sigmask endianness issue in sigreturn, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 32/49] net/tap-win32: Fix gcc 14 format truncation errors, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 21/49] raw-format: Fix error message for invalid offset/size, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 22/49] tcg: Reset data_gen_ptr correctly, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 24/49] target/i386: Use probe_access_full_mmu in ptw_translate, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 25/49] linux-user: Emulate /proc/self/maps under mmap_lock,
Michael Tokarev <=
- [Stable-8.2.8 27/49] vfio/migration: Report only stop-copy size in vfio_state_pending_exact(), Michael Tokarev, 2024/11/09
- [Stable-8.2.8 38/49] target/riscv: Set vtype.vill on CPU reset, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 35/49] target/riscv/csr.c: Fix an access to VXSAT, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 23/49] target/i386: Walk NPT in guest real mode, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 30/49] Fix calculation of minimum in colo_compare_tcp, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 34/49] target/arm: Fix arithmetic underflow in SETM instruction, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 31/49] net: fix build when libbpf is disabled, but libxdp is enabled, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 36/49] target/riscv: Correct SXL return value for RV32 in RV64 QEMU, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 40/49] hw/intc/riscv_aplic: Check and update pending when write sourcecfg, Michael Tokarev, 2024/11/09
- [Stable-8.2.8 39/49] hw/intc/riscv_aplic: Fix in_clrip[x] read emulation, Michael Tokarev, 2024/11/09