summaryrefslogtreecommitdiffstats
path: root/kernel/compat.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-05 18:34:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-05 18:34:35 -0400
commitea3b25e1320df4e575c323b6ab22a5fc79976fbe (patch)
treeee824920b52a6458e383bc2b057cc5508e60fafe /kernel/compat.c
parent89fbf5384ddf666a595eb6562dc63fcbfeb8f6a5 (diff)
parent725816e8aabb1c183baa2bc9572ab9a0d26b9ea1 (diff)
Merge branch 'timers-compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull timer-related user access updates from Al Viro: "Continuation of timers-related stuff (there had been more, but my parts of that series are already merged via timers/core). This is more of y2038 work by Deepa Dinamani, partially disrupted by the unification of native and compat timers-related syscalls" * 'timers-compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: posix_clocks: Use get_itimerspec64() and put_itimerspec64() timerfd: Use get_itimerspec64() and put_itimerspec64() nanosleep: Use get_timespec64() and put_timespec64() posix-timers: Use get_timespec64() and put_timespec64() posix-stubs: Conditionally include COMPAT_SYS_NI defines time: introduce {get,put}_itimerspec64 time: add get_timespec64 and put_timespec64
Diffstat (limited to 'kernel/compat.c')
-rw-r--r--kernel/compat.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index 9ce1d4876e60..0621c8e1ab72 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -120,6 +120,50 @@ static int __compat_put_timespec(const struct timespec *ts, struct compat_timesp
120 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; 120 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
121} 121}
122 122
123static int __compat_get_timespec64(struct timespec64 *ts64,
124 const struct compat_timespec __user *cts)
125{
126 struct compat_timespec ts;
127 int ret;
128
129 ret = copy_from_user(&ts, cts, sizeof(ts));
130 if (ret)
131 return -EFAULT;
132
133 ts64->tv_sec = ts.tv_sec;
134 ts64->tv_nsec = ts.tv_nsec;
135
136 return 0;
137}
138
139static int __compat_put_timespec64(const struct timespec64 *ts64,
140 struct compat_timespec __user *cts)
141{
142 struct compat_timespec ts = {
143 .tv_sec = ts64->tv_sec,
144 .tv_nsec = ts64->tv_nsec
145 };
146 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
147}
148
149int compat_get_timespec64(struct timespec64 *ts, const void __user *uts)
150{
151 if (COMPAT_USE_64BIT_TIME)
152 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
153 else
154 return __compat_get_timespec64(ts, uts);
155}
156EXPORT_SYMBOL_GPL(compat_get_timespec64);
157
158int compat_put_timespec64(const struct timespec64 *ts, void __user *uts)
159{
160 if (COMPAT_USE_64BIT_TIME)
161 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
162 else
163 return __compat_put_timespec64(ts, uts);
164}
165EXPORT_SYMBOL_GPL(compat_put_timespec64);
166
123int compat_get_timeval(struct timeval *tv, const void __user *utv) 167int compat_get_timeval(struct timeval *tv, const void __user *utv)
124{ 168{
125 if (COMPAT_USE_64BIT_TIME) 169 if (COMPAT_USE_64BIT_TIME)
@@ -476,6 +520,27 @@ int put_compat_itimerspec(struct compat_itimerspec __user *dst,
476 return 0; 520 return 0;
477} 521}
478 522
523int get_compat_itimerspec64(struct itimerspec64 *its,
524 const struct compat_itimerspec __user *uits)
525{
526
527 if (__compat_get_timespec64(&its->it_interval, &uits->it_interval) ||
528 __compat_get_timespec64(&its->it_value, &uits->it_value))
529 return -EFAULT;
530 return 0;
531}
532EXPORT_SYMBOL_GPL(get_compat_itimerspec64);
533
534int put_compat_itimerspec64(const struct itimerspec64 *its,
535 struct compat_itimerspec __user *uits)
536{
537 if (__compat_put_timespec64(&its->it_interval, &uits->it_interval) ||
538 __compat_put_timespec64(&its->it_value, &uits->it_value))
539 return -EFAULT;
540 return 0;
541}
542EXPORT_SYMBOL_GPL(put_compat_itimerspec64);
543
479/* 544/*
480 * We currently only need the following fields from the sigevent 545 * We currently only need the following fields from the sigevent
481 * structure: sigev_value, sigev_signo, sig_notify and (sometimes 546 * structure: sigev_value, sigev_signo, sig_notify and (sometimes