qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] c9f806: linux-user: Ensure mmap_min_addr is n


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] c9f806: linux-user: Ensure mmap_min_addr is non-zero
Date: Tue, 28 Jul 2020 10:00:33 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: c9f8066697e0d3e77b97f6df423e9d6540b693be
      
https://github.com/qemu/qemu/commit/c9f8066697e0d3e77b97f6df423e9d6540b693be
  Author: Richard Henderson <richard.henderson@linaro.org>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M linux-user/main.c

  Log Message:
  -----------
  linux-user: Ensure mmap_min_addr is non-zero

When the chroot does not have /proc mounted, we can read neither
/proc/sys/vm/mmap_min_addr nor /proc/sys/maps.

The enforcement of mmap_min_addr in the host kernel is done by
the security module, and so does not apply to processes owned
by root.  Which leads pgd_find_hole_fallback to succeed in probing
a reservation at address 0.  Which confuses pgb_reserved_va to
believe that guest_base has not actually been initialized.

We don't actually want NULL addresses to become accessible, so
make sure that mmap_min_addr is initialized with a non-zero value.

Buglink: https://bugs.launchpad.net/qemu/+bug/1888728
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200724212314.545877-1-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 4d213001b356c4a24c05afbc72f4860088900627
      
https://github.com/qemu/qemu/commit/4d213001b356c4a24c05afbc72f4860088900627
  Author: Filip Bozuta <Filip.Bozuta@syrmia.com>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: Fix syscall rt_sigtimedwait() implementation

Implementation of 'rt_sigtimedwait()' in 'syscall.c' uses the
function 'target_to_host_timespec()' to transfer the value of
'struct timespec' from target to host. However, the implementation
doesn't check whether this conversion succeeds and thus can cause
an unaproppriate error instead of the 'EFAULT (Bad address)' which
is supposed to be set if the conversion from target to host fails.

This was confirmed with the LTP test for rt_sigtimedwait:
"/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c"
which causes an unapropriate error in test case "test_bad_adress3"
which is run with a bad adress for the 'struct timespec' argument:

FAIL: test_bad_address3 (349): Unexpected failure: EAGAIN/EWOULDBLOCK (11)

The test fails with an unexptected errno 'EAGAIN/EWOULDBLOCK' instead
of the expected EFAULT.

After the changes from this patch, the test case is executed successfully
along with the other LTP test cases for 'rt_sigtimedwait()':

PASS: test_bad_address3 (349): Test passed

Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200724181651.167819-1-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 0f6bb1958f3aae0171996941df7fb7ea7536bb12
      
https://github.com/qemu/qemu/commit/0f6bb1958f3aae0171996941df7fb7ea7536bb12
  Author: Andreas Schwab <schwab@suse.de>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: Use getcwd syscall directly

The glibc getcwd function returns different errors than the getcwd
syscall, which triggers an assertion failure in the glibc getcwd function
when running under the emulation.

When the syscall returns ENAMETOOLONG, the glibc wrapper uses a fallback
implementation that potentially handles an unlimited path length, and
returns with ERANGE if the provided buffer is too small.  The qemu
emulation cannot distinguish the two cases, and thus always returns ERANGE.
This is unexpected by the glibc wrapper.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <mvmmu3qplvi.fsf@suse.de>
[lv: updated description]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 0a58e39fe90c50b313a5148c095f8dbb6111a6d6
      
https://github.com/qemu/qemu/commit/0a58e39fe90c50b313a5148c095f8dbb6111a6d6
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2020-07-28 (Tue, 28 Jul 2020)

  Changed paths:
    M linux-user/main.c
    M linux-user/syscall.c

  Log Message:
  -----------
  Merge remote-tracking branch 
'remotes/vivier2/tags/linux-user-for-5.1-pull-request' into staging

linux-user 20200728

Fix "pgb_reserved_va: Assertion `guest_base != 0' failed." error
Fix rt_sigtimedwait() errno
Fix getcwd() errno

# gpg: Signature made Tue 28 Jul 2020 13:34:11 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" 
[full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-5.1-pull-request:
  linux-user: Use getcwd syscall directly
  linux-user: Fix syscall rt_sigtimedwait() implementation
  linux-user: Ensure mmap_min_addr is non-zero

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/a466dd084f51...0a58e39fe90c



reply via email to

[Prev in Thread] Current Thread [Next in Thread]