ソースを参照

[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.

Don Porter 5 年 前
コミット
4fb1278db7
1 ファイル変更3 行追加0 行削除
  1. 3 0
      LibOS/shim/src/sys/shim_sched.c

+ 3 - 0
LibOS/shim/src/sys/shim_sched.c

@@ -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);