[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/15] mips: rlimit incorrectly converts values
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 11/15] mips: rlimit incorrectly converts values |
Date: |
Wed, 13 Jul 2011 17:48:50 +0300 |
From: Wesley W. Terpstra <address@hidden>
Byte swap was applied in the wrong order with testing for
RLIM_INFINITY. On mips bigendian from an amd64 system this results in
infinity being misinterpretted as 2^31-1.
This is a serious bug because it causes setrlimit stack size to kill
all child processes. This means (for example) that 'make' can run no
children. The mechanism of failure:
1. parent sets stack size rlimit to 'infinity'
2. qemu screws this value up
3. child process fetches stack size as a large (but non-infinite) value
4. qemu tries to allocate stack before execution
5. stack allocation fails (too big) and child process dies
Signed-off-by: Wesley W. Terpstra <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 90f6789..4b9e3b8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -934,18 +934,30 @@ static inline abi_long host_to_target_rusage(abi_ulong
target_addr,
static inline rlim_t target_to_host_rlim(target_ulong target_rlim)
{
- if (target_rlim == TARGET_RLIM_INFINITY)
- return RLIM_INFINITY;
+ target_ulong target_rlim_swap;
+ rlim_t result;
+
+ target_rlim_swap = tswapl(target_rlim);
+ if (target_rlim_swap == TARGET_RLIM_INFINITY || target_rlim_swap !=
(rlim_t)target_rlim_swap)
+ result = RLIM_INFINITY;
else
- return tswapl(target_rlim);
+ result = target_rlim_swap;
+
+ return result;
}
static inline target_ulong host_to_target_rlim(rlim_t rlim)
{
+ target_ulong target_rlim_swap;
+ target_ulong result;
+
if (rlim == RLIM_INFINITY || rlim != (target_long)rlim)
- return TARGET_RLIM_INFINITY;
+ target_rlim_swap = TARGET_RLIM_INFINITY;
else
- return tswapl(rlim);
+ target_rlim_swap = rlim;
+ result = tswapl(target_rlim_swap);
+
+ return result;
}
static inline abi_long copy_from_user_timeval(struct timeval *tv,
--
1.7.4.1
- [Qemu-devel] [PATCH 00/15] v2: pending linux-user patches, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 03/15] linux-user: Add support for more VT ioctls, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 04/15] linux-user: Add support for even more FB ioctls, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 05/15] linux-user: Add syscall numbers from kernel 2.6.39.2, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 01/15] arm-semi: Provide access to CLI arguments passed through the "-append" option, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 06/15] linux-user: Implement prlimit64 syscall, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 02/15] linux-user: Add support for KD...LED ioctls, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 07/15] linux-user/syscall.c: Enforce pselect6 sigset size restrictions, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 08/15] mips: sigaltstack args, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 09/15] mips: missing syscall returns wrong errno, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 11/15] mips: rlimit incorrectly converts values,
riku . voipio <=
- [Qemu-devel] [PATCH 10/15] mips: null pointer deref should segfault, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 13/15] linux-user: correct syscall 123 on sh4, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 14/15] linux-user: make MIPS and ARM eabi use same argument reordering, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 12/15] mips: rlimit codes are not the same, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 15/15] linux-user/signal.c: Rename s390 target_ucontext fields to fix ia64, riku . voipio, 2011/07/13