[LibOS] Add a check to sched_getaffinity that the user_mask_ptr is a valid user address. This will make LTP test sched_getaffinity01,5 pass reliably.

This commit is contained in:
Don Porter
2019-01-29 14:56:36 -05:00
parent 8f68c51369
commit 4fb1278db7
+3
View File
@@ -40,6 +40,9 @@ int shim_do_sched_getaffinity (pid_t pid, size_t len,
__kernel_cpu_set_t * user_mask_ptr)
{
int ncpus = PAL_CB(cpu_info.cpu_num);
// Check that user_mask_ptr is valid; if not, should return -EFAULT
if (test_user_memory(user_mask_ptr, len, 1))
return -EFAULT;
memset(user_mask_ptr, 0, len);
for (int i = 0 ; i < ncpus ; i++)
((uint8_t *) user_mask_ptr)[i / 8] |= 1 << (i % 8);