From patchwork Mon Jul 16 16:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142046 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2604182ljj; Mon, 16 Jul 2018 09:12:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfe6aQpx17iZQBYdVr2q+bJrIzKcUimJex+sYDxMNIxu0rgFXA78rsbu2Xq6viWX27GWw1S X-Received: by 2002:a17:902:780d:: with SMTP id p13-v6mr15142470pll.119.1531757529242; Mon, 16 Jul 2018 09:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531757529; cv=none; d=google.com; s=arc-20160816; b=k+3r9WlwWFgvpbOTTuodtviJP6txIflM3QfhW2TcktSFUDsezMZFly0TgX/2DrcFJe ijyQwxeAYYsOWZVsgUg+3COS+DVeAY3IEGJxQ7td5mF3SQmuRaIdRepJysdiXgjY5Yn+ Fsfh7AWDBUXX8jGXZsoCrZWlhqNYejj8SPXS3sNV/gcw2DQvUZ/PXf/iK5XbY76zhnVM OXanVft5MPDxgzZ9cLmGb70aCn2v6/M34KVR0OekCRu027/vGGt+5YruRXg3SU6fv35V yuGGa0ugVbIFyp5QNTHCBEK59RJl6uZdhQ8L36gjMyNEM5mzCdtDAphdtNTLGaWRqKWI tT2Q== 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=jM92TYr38EI8PxJEXuli2RRBR5c1pWqNPCMcYX/yVSc=; b=m+DhhMWdUapBmoZ49RLz6pcc0mrNv2q+26g+ze+cw7ZI7UGE6qEgfk0BvRU3j3fojM zi8HsVO58LhRvdWcayqzWaeh/t0N0ESWdi1Yj0UXz0A6eL9THqCJ7GI48jQwlZhwtK+G hPFgEEuqejeCrkYT5gmRzkB4GieGyZlcU4Lpc/hC9GsNolvaJR5TRpnSEi2zGetC1VI4 LqnAbqMjb/nSB3fvBznPy7viGZnnBsggm5Hk7iLtyI+oY/o4RJHJYcOY1/qeQQQcwPXn Ooog/8Fb/v+/UudyfT0m5A+wxU6fFzOdxQmLJGtjQba7QpHL3GuKfkzzcMeQZtJYXAoK DZpw== 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 x18-v6si30410996pfh.84.2018.07.16.09.12.09; Mon, 16 Jul 2018 09:12:09 -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 S1731117AbeGPQkN (ORCPT + 10 others); Mon, 16 Jul 2018 12:40:13 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:36886 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730897AbeGPQkN (ORCPT ); Mon, 16 Jul 2018 12:40:13 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0May0k-1fLmp90Yqg-00KRIi; Mon, 16 Jul 2018 18:11:13 +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 13/17] y2038: socket: Convert recvmmsg to __kernel_timespec Date: Mon, 16 Jul 2018 18:10:59 +0200 Message-Id: <20180716161103.16239-14-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:5bWc/HsfL0/50LXeDf7poFvAdqUUpdbjEKOGR7+CsFqtOLP/xdu ffvWZpo8nL0gwHtUEb0R5Q6ashnXxfCylMS8438N/BG31lJt6+3mtRdqzKjC4uNMTdelHKm Alk0iSh1EyTXpzsAGLaa5ppJDAlUsNVs9p8P/rHi0t/YkiMP3lJ+E9PIbEMRYcofyj3y9ZE Rr7BgG61CPYjQC83dwY7Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:F+biWiHrHhY=:1qdi6onJMX4jjp/Rs5Hdcf aH193+gx4DNJcQvgjUMKtfeJny2A8YcoBDPgQaJiIzv6mzKFwdj6eTiVnpVdK6ryX6aUJwEN0 EUA4R9Eun2+lOApl2qjR3pF+h/gXdxiPFYPHhpOqeTCwgBx5H0sllev4jQEgQP3v4HzTV2BVr UCkzx4+KN1B/J5lSVCzR8dxa1TNVjxDzDtE2Qk6IUEzVG7nQ25vNqinQxlqIEfY8wTVjcbqKG A2PY26pOfUKqFobh7ho00QL9htdxahELCTx3a3mp6gXl6Op6isArjrfO798R/6JH9gkZRuaPz Sr03QaebRZLkt7sXDaQfYm2ddO2HpiSXw5VSPTwYuk3C7N3nwQPX/XlSDPoBN0SO/xqyKpmp8 Utnmm181wWLJ6vbQozgQG7KjIgGKSMyTs6PnjriyixlSamAstQrM5ShqnoasLD0IX9dttxAr4 WXFq/+XkfJ21WICrvG3Fr4oI/SMODXdhvdY31127UMZllfD9J6w1HDv8m0Md/3dyUP9bjRliC SpqK7/1WweUrkMAXX3pG/iCPluUx6ELSet31zdlJIwZl9bcHY/b9a14+lZx8YuumSTvt7XpEt Q1mxcaDMEI4iHGCYAOJFe4EjizZ/23OnmLMwKie087aX/P9svpr+ikVqoznLzVOVFPKt10U2H 9WQqrZoTshncSRvyK54FZdD4omgPbCsZraDptfX2GZ8RR5z65bL1OIkh7ReU8O9A7rO0= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This converts the recvmmsg() system call in all its variations to use 'timespec64' internally for its timeout, and have a __kernel_timespec64 argument in the native entry point. This lets us change the type to use 64-bit time_t at a later point while using the 32-bit compat system call emulation for existing user space. Signed-off-by: Arnd Bergmann --- include/linux/socket.h | 4 ++-- include/linux/syscalls.h | 2 +- net/compat.c | 6 +++--- net/socket.c | 18 ++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) -- 2.9.0 diff --git a/include/linux/socket.h b/include/linux/socket.h index 7ed4713d5337..8b571e9b9f76 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -348,7 +348,7 @@ struct ucred { extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); -struct timespec; +struct timespec64; /* The __sys_...msg variants allow MSG_CMSG_COMPAT iff * forbid_cmsg_compat==false @@ -358,7 +358,7 @@ extern long __sys_recvmsg(int fd, struct user_msghdr __user *msg, extern long __sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned int flags, bool forbid_cmsg_compat); extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, - unsigned int flags, struct timespec *timeout); + unsigned int flags, struct timespec64 *timeout); extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, bool forbid_cmsg_compat); diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 4fc93fbc0d00..6871f6901a70 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -830,7 +830,7 @@ asmlinkage long sys_perf_event_open( asmlinkage long sys_accept4(int, struct sockaddr __user *, int __user *, int); asmlinkage long sys_recvmmsg(int fd, struct mmsghdr __user *msg, unsigned int vlen, unsigned flags, - struct timespec __user *timeout); + struct __kernel_timespec __user *timeout); asmlinkage long sys_wait4(pid_t pid, int __user *stat_addr, int options, struct rusage __user *ru); diff --git a/net/compat.c b/net/compat.c index 7242cce5631b..0380fbb9a321 100644 --- a/net/compat.c +++ b/net/compat.c @@ -817,18 +817,18 @@ static int __compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, struct compat_timespec __user *timeout) { int datagrams; - struct timespec ktspec; + struct timespec64 ktspec; if (timeout == NULL) return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, NULL); - if (compat_get_timespec(&ktspec, timeout)) + if (compat_get_timespec64(&ktspec, timeout)) return -EFAULT; datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, &ktspec); - if (datagrams > 0 && compat_put_timespec(&ktspec, timeout)) + if (datagrams > 0 && compat_put_timespec64(&ktspec, timeout)) datagrams = -EFAULT; return datagrams; diff --git a/net/socket.c b/net/socket.c index 173d7c949218..c0838a278cfd 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2333,7 +2333,7 @@ SYSCALL_DEFINE3(recvmsg, int, fd, struct user_msghdr __user *, msg, */ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, - unsigned int flags, struct timespec *timeout) + unsigned int flags, struct timespec64 *timeout) { int fput_needed, err, datagrams; struct socket *sock; @@ -2398,8 +2398,7 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, if (timeout) { ktime_get_ts64(&timeout64); - *timeout = timespec64_to_timespec( - timespec64_sub(end_time, timeout64)); + *timeout = timespec64_sub(end_time, timeout64); if (timeout->tv_sec < 0) { timeout->tv_sec = timeout->tv_nsec = 0; break; @@ -2445,10 +2444,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, - struct timespec __user *timeout) + struct __kernel_timespec __user *timeout) { int datagrams; - struct timespec timeout_sys; + struct timespec64 timeout_sys; if (flags & MSG_CMSG_COMPAT) return -EINVAL; @@ -2456,13 +2455,12 @@ static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, if (!timeout) return __sys_recvmmsg(fd, mmsg, vlen, flags, NULL); - if (copy_from_user(&timeout_sys, timeout, sizeof(timeout_sys))) + if (get_timespec64(&timeout_sys, timeout)) return -EFAULT; datagrams = __sys_recvmmsg(fd, mmsg, vlen, flags, &timeout_sys); - if (datagrams > 0 && - copy_to_user(timeout, &timeout_sys, sizeof(timeout_sys))) + if (datagrams > 0 && put_timespec64(&timeout_sys, timeout)) datagrams = -EFAULT; return datagrams; @@ -2470,7 +2468,7 @@ static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, unsigned int, vlen, unsigned int, flags, - struct timespec __user *, timeout) + struct __kernel_timespec __user *, timeout) { return do_sys_recvmmsg(fd, mmsg, vlen, flags, timeout); } @@ -2593,7 +2591,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) break; case SYS_RECVMMSG: err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], - a[3], (struct timespec __user *)a[4]); + a[3], (struct __kernel_timespec __user *)a[4]); break; case SYS_ACCEPT4: err = __sys_accept4(a0, (struct sockaddr __user *)a1,