[PATCH v4 8/9] epoll: Add compat version implementation of epoll_pwait1

From: Fam Zheng
Date: Mon Mar 09 2015 - 21:52:31 EST


Signed-off-by: Fam Zheng <famz@xxxxxxxxxx>
---
fs/eventpoll.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/compat.h | 6 ++++++
2 files changed, 56 insertions(+)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 06a59fc..b837ea4 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2178,6 +2178,56 @@ COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd,
return epoll_pwait_do(epfd, events, maxevents, CLOCK_MONOTONIC, kt,
sigmask ? &ksigmask : NULL);
}
+
+struct compat_epoll_wait_params {
+ int size;
+ int clockid;
+ compat_uptr_t timeout;
+ compat_uptr_t sigmask;
+ compat_size_t sigsetsize;
+} EPOLL_PACKED;
+
+COMPAT_SYSCALL_DEFINE5(epoll_pwait1, int, epfd, int, flags,
+ struct epoll_event __user *, events,
+ int, maxevents,
+ struct compat_epoll_wait_params __user *, params)
+{
+ struct compat_epoll_wait_params p;
+
+ ktime_t kt = { 0 };
+ sigset_t sigmask;
+ compat_sigset_t compat_sigmask;
+ struct timespec timeout;
+
+ if (flags)
+ return -EINVAL;
+ if (!params)
+ return -EINVAL;
+ if (copy_from_user(&p, params, sizeof(p)))
+ return -EFAULT;
+ if (p.size != sizeof(p))
+ return -EINVAL;
+ if (p.sigmask) {
+ if (copy_from_user(&compat_sigmask, compat_ptr(p.sigmask),
+ sizeof(sigmask)))
+ return -EFAULT;
+ if (p.sigsetsize != sizeof(p.sigmask))
+ return -EINVAL;
+ sigset_from_compat(&sigmask, &compat_sigmask);
+ }
+ if (p.timeout) {
+ if (compat_get_timespec(&timeout, compat_ptr(p.timeout)))
+ return -EFAULT;
+ if (!timespec_valid(&timeout))
+ return -EINVAL;
+ kt = timespec_to_ktime(timeout);
+ } else {
+ kt = ns_to_ktime(-1);
+ }
+
+ return epoll_pwait_do(epfd, events, maxevents, p.clockid,
+ kt, p.sigmask ? &sigmask : NULL);
+}
#endif

static int __init eventpoll_init(void)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index ab25814..649c5b2 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -452,6 +452,12 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,
const compat_sigset_t __user *sigmask,
compat_size_t sigsetsize);

+struct compat_epoll_wait_params;
+asmlinkage long compat_sys_epoll_pwait1(int epfd, int flags,
+ struct epoll_event __user *events,
+ int maxevents,
+ struct compat_epoll_wait_params __user *params);
+
asmlinkage long compat_sys_utime(const char __user *filename,
struct compat_utimbuf __user *t);
asmlinkage long compat_sys_utimensat(unsigned int dfd,
--
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/