]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - kernel/sched/core.c
Merge branch 'misc.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[mirror_ubuntu-eoan-kernel.git] / kernel / sched / core.c
index a092f350f3a21ad31c359c704eff65990613853f..75554f366fd3aa20339a00a03d7897cf42bc7d97 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init_task.h>
 #include <linux/context_tracking.h>
 #include <linux/rcupdate_wait.h>
+#include <linux/compat.h>
 
 #include <linux/blkdev.h>
 #include <linux/kprobes.h>
@@ -5107,13 +5108,11 @@ SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
  * Return: On success, 0 and the timeslice is in @interval. Otherwise,
  * an error code.
  */
-SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
-               struct timespec __user *, interval)
+static int sched_rr_get_interval(pid_t pid, struct timespec64 *t)
 {
        struct task_struct *p;
        unsigned int time_slice;
        struct rq_flags rf;
-       struct timespec t;
        struct rq *rq;
        int retval;
 
@@ -5137,15 +5136,40 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
        task_rq_unlock(rq, p, &rf);
 
        rcu_read_unlock();
-       jiffies_to_timespec(time_slice, &t);
-       retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;
-       return retval;
+       jiffies_to_timespec64(time_slice, t);
+       return 0;
 
 out_unlock:
        rcu_read_unlock();
        return retval;
 }
 
+SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
+               struct timespec __user *, interval)
+{
+       struct timespec64 t;
+       int retval = sched_rr_get_interval(pid, &t);
+
+       if (retval == 0)
+               retval = put_timespec64(&t, interval);
+
+       return retval;
+}
+
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
+                      compat_pid_t, pid,
+                      struct compat_timespec __user *, interval)
+{
+       struct timespec64 t;
+       int retval = sched_rr_get_interval(pid, &t);
+
+       if (retval == 0)
+               retval = compat_put_timespec64(&t, interval);
+       return retval;
+}
+#endif
+
 void sched_show_task(struct task_struct *p)
 {
        unsigned long free = 0;