[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 5/5] linux-user: do setrlimit selectively
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL v2 5/5] linux-user: do setrlimit selectively |
Date: |
Tue, 25 Sep 2018 22:51:29 +0200 |
From: Max Filippov <address@hidden>
setrlimit guest calls that affect memory resources
(RLIMIT_{AS,DATA,STACK}) may interfere with QEMU internal memory
management. They may result in QEMU lockup because mprotect call in
page_unprotect would fail with ENOMEM error code, causing infinite loop
of SIGSEGV. E.g. it happens when running libstdc++ testsuite for xtensa
target on x86_64 host.
Don't call host setrlimit for memory-related resources.
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Max Filippov <address@hidden>
Message-Id: <address@hidden>
[lv: rebase on master]
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 019af632df..ae3c0dfef7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7879,7 +7879,21 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur);
rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max);
unlock_user_struct(target_rlim, arg2, 0);
- return get_errno(setrlimit(resource, &rlim));
+ /*
+ * If we just passed through resource limit settings for memory
then
+ * they would also apply to QEMU's own allocations, and QEMU will
+ * crash or hang or die if its allocations fail. Ideally we would
+ * track the guest allocations in QEMU and apply the limits
ourselves.
+ * For now, just tell the guest the call succeeded but don't
actually
+ * limit anything.
+ */
+ if (resource != RLIMIT_AS &&
+ resource != RLIMIT_DATA &&
+ resource != RLIMIT_STACK) {
+ return get_errno(setrlimit(resource, &rlim));
+ } else {
+ return 0;
+ }
}
#endif
#ifdef TARGET_NR_getrlimit
--
2.17.1
- [Qemu-devel] [PULL v2 0/5] Linux user for 3.1 patches, Laurent Vivier, 2018/09/25
- [Qemu-devel] [PULL v2 5/5] linux-user: do setrlimit selectively,
Laurent Vivier <=
- [Qemu-devel] [PULL v2 2/5] linux-user: add SO_LINGER to {g, s}etsockopt, Laurent Vivier, 2018/09/25
- [Qemu-devel] [PULL v2 3/5] linux-user: elf: mmap all the target-pages of hostpage for data segment, Laurent Vivier, 2018/09/25
- [Qemu-devel] [PULL v2 4/5] linux-user: write(fd, NULL, 0) parity with linux's treatment of same, Laurent Vivier, 2018/09/25
- [Qemu-devel] [PULL v2 1/5] linux-user: move TargetFdTrans functions to their own file, Laurent Vivier, 2018/09/25
- Re: [Qemu-devel] [PULL v2 0/5] Linux user for 3.1 patches, Peter Maydell, 2018/09/28