[Qemu-devel] [PATCHv2] linux-user: Fix sched_getaffinity mask size

Samuel Thibault posted 1 patch 6 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180211174704.27441-1-samuel.thibault@ens-lyon.org
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test docker-quick@centos6 passed
Test ppcbe passed
Test ppcle passed
Test s390x passed
linux-user/syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCHv2] linux-user: Fix sched_getaffinity mask size
Posted by Samuel Thibault 6 years, 1 month ago
We properly computed the capped mask size to be put to the application
buffer, but didn't actually used it. Also, we need to return the capped mask
size instead of 0 on success.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
Difference from v1:
- simplify fix
---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 82b35a6bdf..bcda3362fc 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -10493,7 +10493,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     ret = arg2;
                 }
 
-                ret = host_to_target_cpu_mask(mask, mask_size, arg3, arg2);
+                if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) {
+                    goto efault;
+                }
             }
         }
         break;
-- 
2.15.1


Re: [Qemu-devel] [PATCHv2] linux-user: Fix sched_getaffinity mask size
Posted by Laurent Vivier 6 years, 1 month ago
Le 11/02/2018 à 18:47, Samuel Thibault a écrit :
> We properly computed the capped mask size to be put to the application
> buffer, but didn't actually used it. Also, we need to return the capped mask
> size instead of 0 on success.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> ---
> Difference from v1:
> - simplify fix
> ---
>  linux-user/syscall.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 82b35a6bdf..bcda3362fc 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -10493,7 +10493,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>                      ret = arg2;
>                  }
>  
> -                ret = host_to_target_cpu_mask(mask, mask_size, arg3, arg2);
> +                if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) {
> +                    goto efault;
> +                }
>              }
>          }
>          break;
> 

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


Re: [Qemu-devel] [PATCHv2] linux-user: Fix sched_getaffinity mask size
Posted by Laurent Vivier 6 years, 1 month ago
Le 11/02/2018 à 18:47, Samuel Thibault a écrit :
> We properly computed the capped mask size to be put to the application
> buffer, but didn't actually used it. Also, we need to return the capped mask
> size instead of 0 on success.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> ---
> Difference from v1:
> - simplify fix
> ---
>  linux-user/syscall.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 82b35a6bdf..bcda3362fc 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -10493,7 +10493,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>                      ret = arg2;
>                  }
>  
> -                ret = host_to_target_cpu_mask(mask, mask_size, arg3, arg2);
> +                if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) {
> +                    goto efault;
> +                }
>              }
>          }
>          break;
> 

Applied to my 'linux-user-for-2.12' branch.

Thanks,
Laurent