Skip to contentSkip to conversation

linux-user: Fix sched_getaffinity mask size

PATCH Applied Samuel Thibault 2 participants 3 messages Feb 11, 2018 – Feb 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: Fix sched_getaffinity mask size

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.

---
Difference from v1:
- simplify fix

---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
linux-user/syscall.c +3 -1
index 82b35a6bdf..bcda3362fc 100644
@@ -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;
Signature · 1 line
2.15.1
Reviewed-by on v2 1/1
#1 lore raw

Le 11/02/2018 à 18:47, Samuel Thibault a écrit :

Quoted 19 lines

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.

---
Difference from v1:
- simplify fix

---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
linux-user/syscall.c +0 -0
index 82b35a6bdf..bcda3362fc 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10501

Quoted 10 lines
linux-user/syscall.c +3 -1
@@ -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 lore raw
In reply to Samuel Thibault

Le 11/02/2018 à 18:47, Samuel Thibault a écrit :

Quoted 19 lines

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.

---
Difference from v1:
- simplify fix

---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
linux-user/syscall.c +0 -0
index 82b35a6bdf..bcda3362fc 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 10501

Quoted 10 lines
linux-user/syscall.c +3 -1
@@ -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