[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/15] linux-user: allocate heap memory for execve ar
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 05/15] linux-user: allocate heap memory for execve arguments |
Date: |
Wed, 31 May 2017 16:08:17 +0300 |
From: Prasad J Pandit <address@hidden>
Arguments passed to execve(2) call from user program could
be large, allocating stack memory for them via alloca(3) call
would lead to bad behaviour. Use 'g_new0' to allocate memory
for such arguments.
Reported-by: Jann Horn <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 32aba195c5..c8f6efc89c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7985,8 +7985,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
envc++;
}
- argp = alloca((argc + 1) * sizeof(void *));
- envp = alloca((envc + 1) * sizeof(void *));
+ argp = g_new0(char *, argc + 1);
+ envp = g_new0(char *, envc + 1);
for (gp = guest_argp, q = argp; gp;
gp += sizeof(abi_ulong), q++) {
@@ -8047,6 +8047,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
unlock_user(*q, addr, 0);
}
+
+ g_free(argp);
+ g_free(envp);
}
break;
case TARGET_NR_chdir:
--
2.11.0
- [Qemu-devel] [PULL 00/15] Misc linux-user updates, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 02/15] linux-user: fix eventfd, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 01/15] linux-user: call fd_trans_target_to_host_data() for write(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 03/15] linux-user: fix fadvise64_64() on ppc, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 04/15] linux-user: fix inotify, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 05/15] linux-user: allocate heap memory for execve arguments,
riku . voipio <=
- [Qemu-devel] [PULL 08/15] linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 09/15] linux-user: fix ssetmask() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 06/15] linux-user: remove all traces of qemu from /proc/self/cmdline, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 07/15] linux-user: add strace for getuid(), gettid(), getppid(), geteuid(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 10/15] linux-user: fix mismatch of lock/unlock_user() invocations in rt_sigqueinfo() syscall, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 12/15] linux-user: add support for rt_tgsigqueueinfo() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 13/15] linux-user: add rt_tgsigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 14/15] linux-user: fix inconsistent spaces in print_siginfo() output, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 11/15] linux-user: fix argument type declaration of rt_sigqueinfo() syscall, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 15/15] linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo(), riku . voipio, 2017/05/31