From patchwork Tue Mar 10 01:49:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 5973591 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A76599F380 for ; Tue, 10 Mar 2015 01:52:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D98FF2015A for ; Tue, 10 Mar 2015 01:52:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6C7920142 for ; Tue, 10 Mar 2015 01:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbbCJBwW (ORCPT ); Mon, 9 Mar 2015 21:52:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37842 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbbCJBwT (ORCPT ); Mon, 9 Mar 2015 21:52:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2A1pXla016358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Mar 2015 21:51:33 -0400 Received: from ad.nay.redhat.com (dhcp-14-137.nay.redhat.com [10.66.14.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2A1nJND004165; Mon, 9 Mar 2015 21:51:18 -0400 From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Alexander Viro , Andrew Morton , Kees Cook , Andy Lutomirski , David Herrmann , Alexei Starovoitov , Miklos Szeredi , David Drysdale , Oleg Nesterov , "David S. Miller" , Vivek Goyal , Mike Frysinger , "Theodore Ts'o" , Heiko Carstens , Rasmus Villemoes , Rashika Kheria , Hugh Dickins , Mathieu Desnoyers , Fam Zheng , Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Josh Triplett , "Michael Kerrisk (man-pages)" , Paolo Bonzini , Omar Sandoval , Jonathan Corbet , shane.seymour@hp.com, dan.j.rosenberg@gmail.com Subject: [PATCH v4 8/9] epoll: Add compat version implementation of epoll_pwait1 Date: Tue, 10 Mar 2015 09:49:14 +0800 Message-Id: <1425952155-27603-9-git-send-email-famz@redhat.com> In-Reply-To: <1425952155-27603-1-git-send-email-famz@redhat.com> References: <1425952155-27603-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Fam Zheng --- 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,