From: Deepa Dinamani <deepa.kernel@gmail.com>
To: tglx@linutronix.de, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org
Cc: john.stultz@linaro.org, nicolas.pitre@linaro.org, arnd@arndb.de,
y2038@lists.linaro.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 6/8] time: introduce {get,put}_itimerspec64
Date: Sun, 18 Jun 2017 23:45:13 -0700 [thread overview]
Message-ID: <20170619064515.922-7-deepa.kernel@gmail.com> (raw)
In-Reply-To: <20170619064515.922-1-deepa.kernel@gmail.com>
As we change the user space type for the timerfd and posix timer
functions to newer data types, we need some form of conversion
helpers to avoid duplicating that logic.
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
include/linux/compat.h | 4 ++++
include/linux/posix-timers.h | 1 -
include/linux/time.h | 13 +++++++++++++
kernel/compat.c | 22 ++++++++++++++++++++++
kernel/time/time.c | 30 ++++++++++++++++++++++++++++++
5 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 72be68953411..c6547d26f8d3 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -158,6 +158,10 @@ extern int compat_get_timeval(struct timeval *, const void __user *);
extern int compat_put_timeval(const struct timeval *, void __user *);
extern int compat_get_timespec64(struct timespec64 *, const void __user *);
extern int compat_put_timespec64(const struct timespec64 *, void __user *);
+extern int get_compat_itimerspec64(struct itimerspec64 *its,
+ const struct compat_itimerspec __user *uits);
+extern int put_compat_itimerspec64(const struct itimerspec64 *its,
+ struct compat_itimerspec __user *uits);
/*
* This function convert a timespec if necessary and returns a *user
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 667095dbcd37..e508948ab4b9 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -115,5 +115,4 @@ long clock_nanosleep_restart(struct restart_block *restart_block);
void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
void posixtimer_rearm(struct siginfo *info);
-
#endif
diff --git a/include/linux/time.h b/include/linux/time.h
index 36afb579495f..f9858d7e6361 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -12,6 +12,10 @@ int get_timespec64(struct timespec64 *ts,
const struct timespec __user *uts);
int put_timespec64(const struct timespec64 *ts,
struct timespec __user *uts);
+int get_itimerspec64(struct itimerspec64 *it,
+ const struct itimerspec __user *uit);
+int put_itimerspec64(const struct itimerspec64 *it,
+ struct itimerspec __user *uit);
#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
@@ -275,4 +279,13 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
a->tv_nsec = ns;
}
+static inline bool itimerspec64_valid(const struct itimerspec64 *its)
+{
+ if (!timespec64_valid(&(its->it_interval)) ||
+ !timespec64_valid(&(its->it_value)))
+ return false;
+
+ return true;
+}
+
#endif
diff --git a/kernel/compat.c b/kernel/compat.c
index d6559c0c69b0..1b5bd5b9343a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -657,6 +657,28 @@ int put_compat_itimerspec(struct compat_itimerspec __user *dst,
return 0;
}
+int get_compat_itimerspec64(struct itimerspec64 *its,
+ const struct compat_itimerspec __user *uits)
+{
+
+ if (__compat_get_timespec64(&its->it_interval, &uits->it_interval) ||
+ __compat_get_timespec64(&its->it_value, &uits->it_value))
+ return -EFAULT;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(get_compat_itimerspec64);
+
+int put_compat_itimerspec64(const struct itimerspec64 *its,
+ struct compat_itimerspec __user *uits)
+{
+ if (__compat_put_timespec64(&its->it_interval, &uits->it_interval) ||
+ __compat_put_timespec64(&its->it_value, &uits->it_value))
+ return -EFAULT;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(put_compat_itimerspec64);
+
+
COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
struct compat_sigevent __user *, timer_event_spec,
timer_t __user *, created_timer_id)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index fdd55c7681ec..16bdf7a3687e 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -814,3 +814,33 @@ int put_timespec64(const struct timespec64 *ts,
return copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0;
}
EXPORT_SYMBOL_GPL(put_timespec64);
+
+int get_itimerspec64(struct itimerspec64 *it,
+ const struct itimerspec __user *uit)
+{
+ int ret;
+
+ ret = get_timespec64(&it->it_interval, &uit->it_interval);
+ if (ret)
+ return ret;
+
+ ret = get_timespec64(&it->it_value, &uit->it_value);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(get_itimerspec64);
+
+int put_itimerspec64(const struct itimerspec64 *it,
+ struct itimerspec __user *uit)
+{
+ int ret;
+
+ ret = put_timespec64(&it->it_interval, &uit->it_interval);
+ if (ret)
+ return ret;
+
+ ret = put_timespec64(&it->it_value, &uit->it_value);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(put_itimerspec64);
--
2.11.0
next prev parent reply other threads:[~2017-06-19 6:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 6:45 [PATCH 0/8] Isolate time_t data types for clock/timer syscalls Deepa Dinamani
2017-06-19 6:45 ` [PATCH 1/8] time: add get_timespec64 and put_timespec64 Deepa Dinamani
2017-06-19 6:45 ` [PATCH 2/8] nanosleep: Move native and compat syscalls Deepa Dinamani
2017-06-19 6:45 ` [PATCH 3/8] kernel: compat: Move clock and timer " Deepa Dinamani
2017-06-19 6:45 ` [PATCH 4/8] nanosleep: Use get_timespec64() and set_timespec64() Deepa Dinamani
2017-06-19 6:45 ` [PATCH 5/8] posix-timers: Use get_timepsec64() and put_timespec64() Deepa Dinamani
2017-06-19 6:45 ` Deepa Dinamani [this message]
2017-06-19 6:45 ` [PATCH 7/8] posix_clocks: Use get_itimerspec64() and put_itimerspec64() Deepa Dinamani
2017-06-19 6:45 ` [PATCH 8/8] timerfd: " Deepa Dinamani
2017-06-19 7:25 ` [PATCH 0/8] Isolate time_t data types for clock/timer syscalls Al Viro
2017-06-19 19:31 ` Deepa Dinamani
2017-06-19 19:46 ` Al Viro
2017-06-19 20:52 ` Deepa Dinamani
2017-06-19 21:12 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170619064515.922-7-deepa.kernel@gmail.com \
--to=deepa.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=john.stultz@linaro.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.pitre@linaro.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox