diff mbox series

[2/2] linux-user: Fix erroneous conversion in copy_file_range

Message ID 20210503174159.54302-3-thatlemon@gmail.com (mailing list archive)
State New, archived
Headers show
Series linux-user: Small fix for copy_file_range | expand

Commit Message

Giuseppe Musacchio May 3, 2021, 5:41 p.m. UTC
From: Giuseppe Musacchio <thatlemon@gmail.com>

The implicit cast from abi_long to size_t may introduce an intermediate
unwanted sign-extension of the value for 32bit targets running on 64bit
hosts.

Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
---
 linux-user/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Vivier May 3, 2021, 6:47 p.m. UTC | #1
Le 03/05/2021 à 19:41, LemonBoy a écrit :
> From: Giuseppe Musacchio <thatlemon@gmail.com>
> 
> The implicit cast from abi_long to size_t may introduce an intermediate
> unwanted sign-extension of the value for 32bit targets running on 64bit
> hosts.
> 
> Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
> ---
>  linux-user/syscall.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 95d79ddc43..c425dfa278 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -13245,8 +13245,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>                  }
>                  poutoff = &outoff;
>              }
> +            /* Do not sign-extend the count parameter. */
>              ret = get_errno(safe_copy_file_range(arg1, pinoff, arg3, poutoff,
> -                                                 arg5, arg6));
> +                                                 (abi_ulong)arg5, arg6));
>              if (!is_error(ret) && ret > 0) {
>                  if (arg2) {
>                      if (put_user_u64(inoff, arg2)) {
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 95d79ddc43..c425dfa278 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -13245,8 +13245,9 @@  static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
                 poutoff = &outoff;
             }
+            /* Do not sign-extend the count parameter. */
             ret = get_errno(safe_copy_file_range(arg1, pinoff, arg3, poutoff,
-                                                 arg5, arg6));
+                                                 (abi_ulong)arg5, arg6));
             if (!is_error(ret) && ret > 0) {
                 if (arg2) {
                     if (put_user_u64(inoff, arg2)) {