From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: An-Cheng Huang <ancheng@ubnt.com>
Subject: [Qemu-devel] [PATCH 5/7] linux-user: Verify MIPS syscall arguments
Date: Fri, 9 Sep 2011 12:32:29 +0300 [thread overview]
Message-ID: <94c19610a6973ad917d9c154eabfc2ee27bc4f59.1315560307.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1315560307.git.riku.voipio@linaro.org>
From: An-Cheng Huang <ancheng@ubnt.com>
On MIPS, some syscall arguments are taken from the stack. This patch adds
verification such that do_syscall() is only invoked if all arguments
have been successfully taken from the stack.
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: An-Cheng Huang <ancheng@ubnt.com>
---
linux-user/main.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 3df91f3..0cc9148 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2170,11 +2170,22 @@ void cpu_loop(CPUMIPSState *env)
sp_reg = env->active_tc.gpr[29];
switch (nb_args) {
/* these arguments are taken from the stack */
- /* FIXME - what to do if get_user() fails? */
- case 8: get_user_ual(arg8, sp_reg + 28);
- case 7: get_user_ual(arg7, sp_reg + 24);
- case 6: get_user_ual(arg6, sp_reg + 20);
- case 5: get_user_ual(arg5, sp_reg + 16);
+ case 8:
+ if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
+ goto done_syscall;
+ }
+ case 7:
+ if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
+ goto done_syscall;
+ }
+ case 6:
+ if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
+ goto done_syscall;
+ }
+ case 5:
+ if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) {
+ goto done_syscall;
+ }
default:
break;
}
@@ -2185,6 +2196,7 @@ void cpu_loop(CPUMIPSState *env)
env->active_tc.gpr[7],
arg5, arg6, arg7, arg8);
}
+done_syscall:
if (ret == -TARGET_QEMU_ESIGRETURN) {
/* Returning from a successful sigreturn syscall.
Avoid clobbering register state. */
--
1.7.4.1
next prev parent reply other threads:[~2011-09-09 9:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 9:32 [Qemu-devel] [PATCH 0/7] pending linux-user patches riku.voipio
2011-09-09 9:32 ` [Qemu-devel] [PATCH 1/7] linux-user: Fix initialization of the heap contents when allocating new pages riku.voipio
2011-09-09 9:32 ` [Qemu-devel] [PATCH 2/7] linux-user: Implement new ARM 64 bit cmpxchg kernel helper riku.voipio
2011-09-09 9:32 ` [Qemu-devel] [PATCH 3/7] linux-user: Exit with an error if we couldn't set up gdbserver riku.voipio
2011-09-09 9:32 ` [Qemu-devel] [PATCH 4/7] linux-user: Fix MIPS indirect syscall handling riku.voipio
2011-09-09 9:32 ` riku.voipio [this message]
2011-09-09 9:32 ` [Qemu-devel] [PATCH 6/7] linux-user: Implement setxattr/getxattr/removexattr syscalls riku.voipio
2011-09-09 9:32 ` [Qemu-devel] [PATCH 7/7] introduce environment variables for all qemu-user options riku.voipio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94c19610a6973ad917d9c154eabfc2ee27bc4f59.1315560307.git.riku.voipio@linaro.org \
--to=riku.voipio@linaro.org \
--cc=ancheng@ubnt.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).