From patchwork Mon Jul 16 16:10:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142054 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2604556ljj; Mon, 16 Jul 2018 09:12:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcR+uVwTRbezFK359B0JVNgb2hjs5jZtscRdVowL+D9SCPEoMf8bz56EAHAdNuRmIJIlVd5 X-Received: by 2002:a63:d15:: with SMTP id c21-v6mr16316787pgl.322.1531757551569; Mon, 16 Jul 2018 09:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531757551; cv=none; d=google.com; s=arc-20160816; b=o8647shYYxxrPLvyvV8oTHY0/3B8gtGh9llUBLNiMZEaIAtPIxD0RmfhFkrUaEoCcD zU4DQN8W13ilT+4YWN2slcvbCeO+anWbKjGLEmcVNajxWWNt11xvOc0Qh4dPJ8qX4i+K 9Jt4NNtAgS6Sy684gaUAKP4Di7svIhRYL0Z32U5Q3AePj3OCyP1cewhN+EWPBXby5aSU dnJ3kk2jVP9t2gDGYwR9It5Q7RXvSNd33PexuUQlKeXumzq2mzG5H6urpSeFUoAEXyz5 6MP4STPKhG9p3K/4MW4KD25LuJgp5h/SdWQNnMkB6wV75tKW4y608TUmiH1WxZdJ/RhK i/WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=GfF7HocEVZK1W6cuTeSo3UFl01CcpZK4U45naFYaGGI=; b=OefaZHuthTqM1/czB4uYIbTfpxlA2WqptzGku90HJGEp7lwxCVhEcLf3Obp1xHaL4/ uptSED+7la+QJMMe316S6I6UGm32T2jZ1jx5bEFUyZSCXQy4PzgXoT6Uomt1EJfDWhea NMRcOlPsA4HoUSv+E+DnggF7VXUChZ0u5CGDXneqvWb0/8SEtdZZ6ybI8lRGSqztofpr UOXIRzARgGIdaMr7KOv6l9MHVbAvHOM4aN+v65xW19Qfbf2pgarLkeLP6ZXg+WT7467P tnARuwmjOp3Ml5bR+1Ny0w+ZWFiyr/xPs7GbqHxUQg4AzkKn2J/wqsjAiFnC0WpCdv2j bRIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si30064885pgc.650.2018.07.16.09.12.31; Mon, 16 Jul 2018 09:12:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbeGPQkJ (ORCPT + 10 others); Mon, 16 Jul 2018 12:40:09 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:59874 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730229AbeGPQkJ (ORCPT ); Mon, 16 Jul 2018 12:40:09 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0LthqL-1g4V9x2h1B-011Euh; Mon, 16 Jul 2018 18:11:12 +0200 From: Arnd Bergmann To: tglx@linutronix.de Cc: y2038@lists.linaro.org, hch@infradead.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, albert.aribaud@3adev.fr, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, peterz@infradead.org, dvhart@infradead.org, ebiederm@xmission.com, linux@dominikbrodowski.net, Arnd Bergmann Subject: [PATCH v2 12/17] y2038: aio: Prepare sys_io_{p, }getevents for __kernel_timespec Date: Mon, 16 Jul 2018 18:10:58 +0200 Message-Id: <20180716161103.16239-13-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180716161103.16239-1-arnd@arndb.de> References: <20180716161103.16239-1-arnd@arndb.de> X-Provags-ID: V03:K1:a3KpSrkjY4tJOq+MSle/NPLPP0gxPpg5PEIvtEgjC02x9fA7SnJ hbu2nhxm+9ux/NXSGzVbTjULSwOa/BYubElV/6yy4V8gijGVxnpKOX1rjuiPPvHZogWCKXx vyemW+nXUlkcpaExioQFSCPKTs4mODKAXBu6o7C711JTjkDfeGNaj0l8eoP54TfTf3F3qep MwTK2tNzjKVIDS30PNPGw== X-UI-Out-Filterresults: notjunk:1; V01:K0:/gMvg9jEAq4=:URz0SuCnEXhL7h1tH/Mu2O VyeWBb/kpuDv769N8QqlYF9SwxTv5UGmCPzdJicZo6lsf5nkxKJE2L3iNVs/K3eOyvcht8wes BbvNCQLGyPDcXTAtaWhgHAxMB6FakdEMB3K7+eisv0odH+pPIkljvbglm/V0POIuo/QLhVQy5 dg2Wg8vk4rR5rdEel04ndO+13PTmjQvABauRYTphrrxUV8/5qoivnyGw0N4CQnzO/SOfb2JpL UkNK3NASLUBnSRqyN7WemOvuS2AMb45K+hFTQkJifmd6xeZAGMQb5MUXraHYaCCpbrhhbZVSm Ex7bAaCx6O0ARcVcKaOiAezpo14S3FOT5uNEBmWyVEcmwoeNZhgGqbsrvBmZubhHg1jiMzAz0 cry6AcjS/4sNLIyD8HVnSLAGMdz8IMWrYUIaD/C0A28t+CEFAqp4AkER5gbE9k2WrjCaaI4R9 b7Zk44KJI+HjNrprCziEqMmWi2zMWxLnjNTrKjv5Sp0s+fs9o2felC9jaxYh45f/eATDHkrfX Sz169dy3CMheFyR4LW7ZzycRZFcmG10UHK19bwg7BK0o8ttj3nfB6W9pAsb82F/7+IOjr2Kt3 Z+db+HkZztJFBKt7AK3J76T+49XPzgqfVLr9U2ogt9J4Oj28u78pGOWHz9MmFNTBFRoTAOOy0 o5t8ZPdByyVWbYoPwgW65LN7vdZj8FdW50+srMJrVCU4gTXY1NhXJ2cakNKrJ1rVoUMY= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a preparation patch for converting sys_io_pgetevents to work with 64-bit time_t on 32-bit architectures. The 'timeout' argument is changed to struct __kernel_timespec, which will be redefined using 64-bit time_t in the future. The compat version of the system call in turn is enabled for compilation with CONFIG_COMPAT_32BIT_TIME so the individual 32-bit architectures can share the handling of the traditional argument with 64-bit architectures providing it for their compat mode. We now have five entry points into do_io_getevents(). Until we set CONFIG_64BIT_TIME, the arguments are sys_io_getevents(): native aio_context_t, old-style timespec sys_io_pgetevents(): like sys_io_getevents(), but with added aio_sigset argument compat_sys_io_getevents(): 32-bit aio_context_t, 32-bit timespec compat_sys_io_pgetevents(): like compat_sys_io_getevents(), but with added aio_sigset argument compat_sys_io_pgetevents_time64(): like compat_sys_io_pgetevents(), but with 64-bit timespec Once a 32-bit architecture sets CONFIG_64BIT_TIME, sys_io_getevents() is no longer available, and sys_io_pgetevents() takes a 64-bit timespec argument, whiel compat_sys_io_getevents() and compat_sys_io_pgetevents() implement the traditional behavior. compat_sys_io_pgetevents_time64() is only used on 64-bit architectures, to provide compatibility with the new 32-bit version of sys_io_pgetevents() taking a 64-bit timespec combined with a __compat_aio_sigset. Signed-off-by: Arnd Bergmann --- fs/aio.c | 77 +++++++++++++++++++++++++++++++++++++++++++----- include/linux/syscalls.h | 4 +-- 2 files changed, 71 insertions(+), 10 deletions(-) -- 2.9.0 diff --git a/fs/aio.c b/fs/aio.c index 76def7523ece..f306a48b0a9f 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1869,7 +1869,7 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id, long, min_nr, long, nr, struct io_event __user *, events, - struct timespec __user *, timeout) + struct __kernel_timespec __user *, timeout) { struct timespec64 ts; int ret; @@ -1888,7 +1888,7 @@ SYSCALL_DEFINE6(io_pgetevents, long, min_nr, long, nr, struct io_event __user *, events, - struct timespec __user *, timeout, + struct __kernel_timespec __user *, timeout, const struct __aio_sigset __user *, usig) { struct __aio_sigset ksig = { NULL, }; @@ -1929,6 +1929,73 @@ SYSCALL_DEFINE6(io_pgetevents, } #ifdef CONFIG_COMPAT +struct __compat_aio_sigset { + compat_sigset_t __user *sigmask; + compat_size_t sigsetsize; +}; + +COMPAT_SYSCALL_DEFINE6(io_pgetevents_time64, + compat_aio_context_t, ctx_id, + compat_long_t, min_nr, + compat_long_t, nr, + struct io_event __user *, events, + struct __kernel_timespec __user *, timeout, + const struct __compat_aio_sigset __user *, usig) +{ + struct __compat_aio_sigset ksig = { NULL, }; + sigset_t ksigmask, sigsaved; + struct timespec64 t; + int ret; + + if (timeout && get_timespec64(&t, timeout)) + return -EFAULT; + + if (usig && copy_from_user(&ksig, usig, sizeof(ksig))) + return -EFAULT; + + if (ksig.sigmask) { + if (ksig.sigsetsize != sizeof(compat_sigset_t)) + return -EINVAL; + if (get_compat_sigset(&ksigmask, ksig.sigmask)) + return -EFAULT; + sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP)); + sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved); + } + + ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &t : NULL); + if (signal_pending(current)) { + if (ksig.sigmask) { + current->saved_sigmask = sigsaved; + set_restore_sigmask(); + } + if (!ret) + ret = -ERESTARTNOHAND; + } else { + if (ksig.sigmask) + sigprocmask(SIG_SETMASK, &sigsaved, NULL); + } + + return ret; +} +#endif + +#ifdef CONFIG_COMPAT_32BIT_TIME +#ifndef CONFIG_COMPAT +#define compat_sigset_t sigset_t +struct __compat_aio_sigset { + compat_sigset_t __user *sigmask; + compat_size_t sigsetsize; +}; + +static inline int get_compat_sigset(sigset_t *set, const sigset_t __user *compat) +{ + if (copy_from_user(set, compat, sizeof *set)) + return -EFAULT; + + return 0; +} +#endif + COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id, compat_long_t, min_nr, compat_long_t, nr, @@ -1947,12 +2014,6 @@ COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id, return ret; } - -struct __compat_aio_sigset { - compat_sigset_t __user *sigmask; - compat_size_t sigsetsize; -}; - COMPAT_SYSCALL_DEFINE6(io_pgetevents, compat_aio_context_t, ctx_id, compat_long_t, min_nr, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 1a22bb4285bf..4fc93fbc0d00 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -296,12 +296,12 @@ asmlinkage long sys_io_getevents(aio_context_t ctx_id, long min_nr, long nr, struct io_event __user *events, - struct timespec __user *timeout); + struct __kernel_timespec __user *timeout); asmlinkage long sys_io_pgetevents(aio_context_t ctx_id, long min_nr, long nr, struct io_event __user *events, - struct timespec __user *timeout, + struct __kernel_timespec __user *timeout, const struct __aio_sigset *sig); /* fs/xattr.c */