[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.0.3 60/69] linux-user: Preserve NULL hit in target_mmap subrou
From: |
Michael Tokarev |
Subject: |
[Stable-9.0.3 60/69] linux-user: Preserve NULL hit in target_mmap subroutines |
Date: |
Fri, 6 Sep 2024 14:13:09 +0300 |
From: Richard Henderson <richard.henderson@linaro.org>
Do not pass guest_base to the host mmap instead of zero hint.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2353
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 3aefee3ec01e607529a9918e2978f365c5c3b5e9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index be3b9a68eb..2a11d921ab 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -559,9 +559,13 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len,
int host_prot, int flags, int page_flags,
int fd, off_t offset)
{
- void *p, *want_p = g2h_untagged(start);
+ void *p, *want_p = NULL;
abi_ulong last;
+ if (start || (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
+ want_p = g2h_untagged(start);
+ }
+
p = mmap(want_p, len, host_prot, flags, fd, offset);
if (p == MAP_FAILED) {
return -1;
@@ -609,11 +613,15 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong
len, int host_prot,
int mmap_flags, int page_flags, int fd,
off_t offset, int host_page_size)
{
- void *p, *want_p = g2h_untagged(start);
+ void *p, *want_p = NULL;
off_t fileend_adj = 0;
int flags = mmap_flags;
abi_ulong last, pass_last;
+ if (start || (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
+ want_p = g2h_untagged(start);
+ }
+
if (!(flags & MAP_ANONYMOUS)) {
struct stat sb;
@@ -739,12 +747,16 @@ static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong
len,
int flags, int page_flags, int fd,
off_t offset, int host_page_size)
{
- void *p, *want_p = g2h_untagged(start);
+ void *p, *want_p = NULL;
off_t host_offset = offset & -host_page_size;
abi_ulong last, real_start, real_last;
bool misaligned_offset = false;
size_t host_len;
+ if (start || (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
+ want_p = g2h_untagged(start);
+ }
+
if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
/*
* Adjust the offset to something representable on the host.
--
2.39.2
- [Stable-9.0.3 50/69] nbd/server: CVE-2024-7409: Avoid use-after-free when closing server, (continued)
- [Stable-9.0.3 50/69] nbd/server: CVE-2024-7409: Avoid use-after-free when closing server, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 51/69] net: Fix '-net nic, model=' for non-help arguments, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 52/69] hw/core/ptimer: fix timer zero period condition for freq > 1GHz, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 53/69] block/blkio: use FUA flag on write zeroes only if supported, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 54/69] target/i386: Do not apply REX to MMX operands, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 55/69] target/arm: Clear high SVE elements in handle_vec_simd_wshli, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 56/69] target/arm: Update translation regime comment for new features, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 57/69] target/arm: Fix usage of MMU indexes when EL3 is AArch32, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 58/69] module: Prevent crash by resetting local_err in module_load_qom_all(), Michael Tokarev, 2024/09/06
- [Stable-9.0.3 59/69] target/hexagon: don't look for static glib, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 60/69] linux-user: Preserve NULL hit in target_mmap subroutines,
Michael Tokarev <=
- [Stable-9.0.3 61/69] target/sparc: Restrict STQF to sparcv9, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 62/69] crypto/tlscredspsk: Free username on finalize, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 63/69] hw/nvme: fix leak of uninitialized memory in io_mgmt_recv, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 64/69] virtio-pci: Fix the use of an uninitialized irqfd, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 65/69] migration/multifd: Free MultiFDRecvParams::data, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 66/69] linux-user: Handle short reads in mmap_h_gt_g, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 68/69] hw/audio/virtio-snd: fix invalid param check, Michael Tokarev, 2024/09/06
- [Stable-9.0.3 67/69] Revert "replay: stop us hanging in rr_wait_io_event", Michael Tokarev, 2024/09/06
- [Stable-9.0.3 69/69] target/hppa: Fix PSW V-bit packaging in cpu_hppa_get for hppa64, Michael Tokarev, 2024/09/06