qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/3] linux-user: Verify MIPS syscall arguments
@ 2011-08-09 19:32 An-Cheng Huang
  2011-08-09 20:38 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: An-Cheng Huang @ 2011-08-09 19:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, riku.voipio

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: 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 cd6750b..77e8f87 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2090,11 +2090,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;
                 }
@@ -2105,6 +2116,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.2.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] linux-user: Verify MIPS syscall arguments
  2011-08-09 19:32 [Qemu-devel] [PATCH 2/3] linux-user: Verify MIPS syscall arguments An-Cheng Huang
@ 2011-08-09 20:38 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2011-08-09 20:38 UTC (permalink / raw)
  To: An-Cheng Huang; +Cc: riku.voipio, qemu-devel

On 9 August 2011 20:32, An-Cheng Huang <ancheng@ubnt.com> wrote:
> 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: An-Cheng Huang <ancheng@ubnt.com>

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

-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-09 20:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 19:32 [Qemu-devel] [PATCH 2/3] linux-user: Verify MIPS syscall arguments An-Cheng Huang
2011-08-09 20:38 ` Peter Maydell

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).