sched: Disallow sched_attr::sched_policy < 0
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / sched / core.c
index 6edbef2..dbe44b5 100644 (file)
@@ -3338,6 +3338,15 @@ recheck:
                                return -EPERM;
                }
 
+                /*
+                 * Can't set/change SCHED_DEADLINE policy at all for now
+                 * (safest behavior); in the future we would like to allow
+                 * unprivileged DL tasks to increase their relative deadline
+                 * or reduce their runtime (both ways reducing utilization)
+                 */
+               if (dl_policy(policy))
+                       return -EPERM;
+
                /*
                 * Treat SCHED_IDLE as nice 20. Only allow a switch to
                 * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
@@ -3674,6 +3683,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
        if (sched_copy_attr(uattr, &attr))
                return -EFAULT;
 
+       if (attr.sched_policy < 0)
+               return -EINVAL;
+
        rcu_read_lock();
        retval = -ESRCH;
        p = find_process_by_pid(pid);