aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-09-19 18:17:46 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-09-20 00:30:57 -0400
commitabca5fc535a3ee0f36fb6d4468a453eaae769921 (patch)
treeb3aac69994bdf81ace541980530704e800f20dce
parent7bea578b5f0c44c974a585bfbe6422065b9f6b6d (diff)
sched_rr_get_interval(): move compat to native, get rid of set_fs()
switch to using timespec64 internally, while we are at it Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--kernel/compat.c16
-rw-r--r--kernel/sched/core.c36
2 files changed, 30 insertions, 22 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index a46a4a40bb8b..d1cee656a7ed 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -562,22 +562,6 @@ COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
562} 562}
563#endif 563#endif
564 564
565COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
566 compat_pid_t, pid,
567 struct compat_timespec __user *, interval)
568{
569 struct timespec t;
570 int ret;
571 mm_segment_t old_fs = get_fs();
572
573 set_fs(KERNEL_DS);
574 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
575 set_fs(old_fs);
576 if (compat_put_timespec(&t, interval))
577 return -EFAULT;
578 return ret;
579}
580
581/* 565/*
582 * Allocate user-space memory for the duration of a single system call, 566 * Allocate user-space memory for the duration of a single system call,
583 * in order to marshall parameters inside a compat thunk. 567 * in order to marshall parameters inside a compat thunk.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 18a6966567da..e74f0a5a8647 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -16,6 +16,7 @@
16#include <linux/init_task.h> 16#include <linux/init_task.h>
17#include <linux/context_tracking.h> 17#include <linux/context_tracking.h>
18#include <linux/rcupdate_wait.h> 18#include <linux/rcupdate_wait.h>
19#include <linux/compat.h>
19 20
20#include <linux/blkdev.h> 21#include <linux/blkdev.h>
21#include <linux/kprobes.h> 22#include <linux/kprobes.h>
@@ -5098,13 +5099,11 @@ SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
5098 * Return: On success, 0 and the timeslice is in @interval. Otherwise, 5099 * Return: On success, 0 and the timeslice is in @interval. Otherwise,
5099 * an error code. 5100 * an error code.
5100 */ 5101 */
5101SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, 5102static int sched_rr_get_interval(pid_t pid, struct timespec64 *t)
5102 struct timespec __user *, interval)
5103{ 5103{
5104 struct task_struct *p; 5104 struct task_struct *p;
5105 unsigned int time_slice; 5105 unsigned int time_slice;
5106 struct rq_flags rf; 5106 struct rq_flags rf;
5107 struct timespec t;
5108 struct rq *rq; 5107 struct rq *rq;
5109 int retval; 5108 int retval;
5110 5109
@@ -5128,15 +5127,40 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
5128 task_rq_unlock(rq, p, &rf); 5127 task_rq_unlock(rq, p, &rf);
5129 5128
5130 rcu_read_unlock(); 5129 rcu_read_unlock();
5131 jiffies_to_timespec(time_slice, &t); 5130 jiffies_to_timespec64(time_slice, t);
5132 retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0; 5131 return 0;
5133 return retval;
5134 5132
5135out_unlock: 5133out_unlock:
5136 rcu_read_unlock(); 5134 rcu_read_unlock();
5137 return retval; 5135 return retval;
5138} 5136}
5139 5137
5138SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
5139 struct timespec __user *, interval)
5140{
5141 struct timespec64 t;
5142 int retval = sched_rr_get_interval(pid, &t);
5143
5144 if (retval == 0)
5145 retval = put_timespec64(&t, interval);
5146
5147 return retval;
5148}
5149
5150#ifdef CONFIG_COMPAT
5151COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
5152 compat_pid_t, pid,
5153 struct compat_timespec __user *, interval)
5154{
5155 struct timespec64 t;
5156 int retval = sched_rr_get_interval(pid, &t);
5157
5158 if (retval == 0)
5159 retval = compat_put_timespec64(&t, interval);
5160 return retval;
5161}
5162#endif
5163
5140void sched_show_task(struct task_struct *p) 5164void sched_show_task(struct task_struct *p)
5141{ 5165{
5142 unsigned long free = 0; 5166 unsigned long free = 0;