Commit 83f5d1266926c75890f1bc4678e49d79483cb573
Committed by
Linus Torvalds
1 parent
57ac889850
Exists in
master
and in
7 other branches
signal/timer/event: timerfd compat code
This patch implements the necessary compat code for the timerfd system call. Signed-off-by: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 32 additions and 4 deletions Side-by-side Diff
fs/compat.c
... | ... | @@ -2224,4 +2224,27 @@ |
2224 | 2224 | } |
2225 | 2225 | |
2226 | 2226 | #endif /* CONFIG_SIGNALFD */ |
2227 | + | |
2228 | +#ifdef CONFIG_TIMERFD | |
2229 | + | |
2230 | +asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags, | |
2231 | + const struct compat_itimerspec __user *utmr) | |
2232 | +{ | |
2233 | + long res; | |
2234 | + struct itimerspec t; | |
2235 | + struct itimerspec __user *ut; | |
2236 | + | |
2237 | + res = -EFAULT; | |
2238 | + if (get_compat_itimerspec(&t, utmr)) | |
2239 | + goto err_exit; | |
2240 | + ut = compat_alloc_user_space(sizeof(*ut)); | |
2241 | + if (copy_to_user(ut, &t, sizeof(t)) ) | |
2242 | + goto err_exit; | |
2243 | + | |
2244 | + res = sys_timerfd(ufd, clockid, flags, ut); | |
2245 | +err_exit: | |
2246 | + return res; | |
2247 | +} | |
2248 | + | |
2249 | +#endif /* CONFIG_TIMERFD */ |
include/linux/compat.h
... | ... | @@ -225,6 +225,11 @@ |
225 | 225 | return lhs->tv_nsec - rhs->tv_nsec; |
226 | 226 | } |
227 | 227 | |
228 | +extern int get_compat_itimerspec(struct itimerspec *dst, | |
229 | + const struct compat_itimerspec __user *src); | |
230 | +extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, | |
231 | + const struct itimerspec *src); | |
232 | + | |
228 | 233 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); |
229 | 234 | |
230 | 235 | extern int compat_printk(const char *fmt, ...); |
kernel/compat.c
... | ... | @@ -475,8 +475,8 @@ |
475 | 475 | return min_length; |
476 | 476 | } |
477 | 477 | |
478 | -static int get_compat_itimerspec(struct itimerspec *dst, | |
479 | - struct compat_itimerspec __user *src) | |
478 | +int get_compat_itimerspec(struct itimerspec *dst, | |
479 | + const struct compat_itimerspec __user *src) | |
480 | 480 | { |
481 | 481 | if (get_compat_timespec(&dst->it_interval, &src->it_interval) || |
482 | 482 | get_compat_timespec(&dst->it_value, &src->it_value)) |
... | ... | @@ -484,8 +484,8 @@ |
484 | 484 | return 0; |
485 | 485 | } |
486 | 486 | |
487 | -static int put_compat_itimerspec(struct compat_itimerspec __user *dst, | |
488 | - struct itimerspec *src) | |
487 | +int put_compat_itimerspec(struct compat_itimerspec __user *dst, | |
488 | + const struct itimerspec *src) | |
489 | 489 | { |
490 | 490 | if (put_compat_timespec(&src->it_interval, &dst->it_interval) || |
491 | 491 | put_compat_timespec(&src->it_value, &dst->it_value)) |