diff mbox

Fix emulation of splice syscall

Message ID mvmsieliqel.fsf@hawking.suse.de
State New
Headers show

Commit Message

Andreas Schwab Feb. 4, 2015, 4:37 p.m. UTC
The second and fourth argument are in/out parameters, store them back
after the syscall.  Also, the fourth argument was mishandled, and EFAULT
handling was missing.

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 linux-user/syscall.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Peter Maydell Feb. 4, 2015, 8:20 p.m. UTC | #1
On 4 February 2015 at 16:37, Andreas Schwab <schwab@suse.de> wrote:
> The second and fourth argument are in/out parameters, store them back
> after the syscall.  Also, the fourth argument was mishandled, and EFAULT
> handling was missing.
>
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>  linux-user/syscall.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index d4398b9..db2f5c7 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9345,14 +9345,24 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>              loff_t loff_in, loff_out;
>              loff_t *ploff_in = NULL, *ploff_out = NULL;
>              if(arg2) {
> -                get_user_u64(loff_in, arg2);
> +                if (get_user_u64(loff_in, arg2))
> +                    goto efault;

Coding style demands braces for all these if statements. Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
Andreas Schwab Feb. 5, 2015, 8:20 a.m. UTC | #2
Peter Maydell <peter.maydell@linaro.org> writes:

> Coding style demands braces for all these if statements.

That must be a recent change.

Andreas.
Peter Maydell Feb. 5, 2015, 8:31 a.m. UTC | #3
On 5 February 2015 at 08:20, Andreas Schwab <schwab@suse.de> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> Coding style demands braces for all these if statements.
>
> That must be a recent change.

It's been documented in CODING_STYLE since we first
wrote down our style choices in 2009...

There is of course still a fair amount of older code which
doesn't follow the style, but we try to follow it for new
code that gets added.

-- PMM
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d4398b9..db2f5c7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9345,14 +9345,24 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             loff_t loff_in, loff_out;
             loff_t *ploff_in = NULL, *ploff_out = NULL;
             if(arg2) {
-                get_user_u64(loff_in, arg2);
+                if (get_user_u64(loff_in, arg2))
+                    goto efault;
                 ploff_in = &loff_in;
             }
-            if(arg4) {
-                get_user_u64(loff_out, arg2);
+            if (arg4) {
+                if (get_user_u64(loff_out, arg4))
+                    goto efault;
                 ploff_out = &loff_out;
             }
             ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
+            if (arg2) {
+                if (put_user_u64(loff_in, arg2))
+                    goto efault;
+            }
+            if (arg4) {
+                if (put_user_u64(loff_out, arg4))
+                    goto efault;
+	    }
         }
         break;
 #endif