From patchwork Wed Apr 25 16:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134352 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1050759lji; Wed, 25 Apr 2018 09:05:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+zRlfngU90GMh4fIfjVIyw/+dKJa0uvDrZe06Z6SO0y1gljhlp7d/OmphbOdyKAtE6H+JI X-Received: by 2002:a17:902:9886:: with SMTP id s6-v6mr29514280plp.380.1524672307159; Wed, 25 Apr 2018 09:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672307; cv=none; d=google.com; s=arc-20160816; b=YcDdYC3XdW+E6aMciDTqBnX6jh6Kqauwd1YpZ9duys53JHe/dx/0I4/1XEh9JUVPqp Wf8vsL+DeCay2/fJeP4MHjq4BaUP2s/G41LSZSLTMDWn2fprPuDT8jdYIVK4OMStsGU0 AVi5LFTCKL2NK9yu/TEr8j13xUYQi2dqWCrwQNcRdvDmWyyC6AmI85sl2IfXUpKM2GVA XaQqiYivPiyxP4u5spHaXYPm7TLQ5oDRgLy7A6D2upuyhhLRNz3TdEnbpDRZ4yN8ICyH Tnne1iM7/iSGpBfohagiaIlTFKOJLWyVRH/vCe/JDHcJcPTEfKZaPlFZE3NoyO6nJxDr jzCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Xi6M927Wn09aZe2xh41/BbO68+oKSE1kgE/shZ6GWv0=; b=qtMILGdbG1vdlhkvdoEyOxDnheRkARziawZQBnSuzqIWCmnESLTRAKHzPy/d+oR5UQ Yo2UuivKnZeFdbvL4C3WY7aFdk2H/1QpYRfyjwXvu7ArRKVQtbHPEzHh6fwN4nqcfhK4 C77CYi8ZpjAUNIbANcRxdduqWeYJ8JOUHiFvIEKITF0/NEVav2MbuEOmti/s1q13bGFm WCrsyhwkwk1IRwFLgBYmDqyFt8/qu36GEpPS8fWPVKlUx7ZKOQ1FS3E0TX4cU4YtcOBW LOJfPD9Cwp9ZI0vvlscNXC0fkon6Zvw6xYLE/DUWHsNIRYukTk4rtjFaZJ+Lg0FBElBz 5Szg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WKpnPtJ7; spf=pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91843-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s85si16365004pfi.32.2018.04.25.09.05.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:05:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WKpnPtJ7; spf=pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91843-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=YcqtKTTSUNBCtkbdj3F14mY2ezi4YKx +YU0l3F82UvkpHWnM0jOIolacqv4F0hbTgqJ881lM0JHPfySE5CNvE9nJZj/2GyA l8IBa/JhyzVywqFlTJShb5jjpAOspIVGURaIg074hj3BbXY46yxJYdSP2MmMhAWe M+jLipQpwhqo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=YK32kMQ/JLGi9Jn1A4xYDNEWLBY=; b=WKpnP tJ7TWXWHwNuLOS5NgC/vt8sBKS8qHFiR3D7ajeYBLCxUOeDTEaTvF2xZ1zDf+h4e DlKMHoJfhAq0zIAPS+AA4ARVgH2iD0qeyQOCgypMnZ9kIdmtPg89S8FzaAImExyi BJKGcLV2eyM52A4G8091qtB5CISkIRRRuMiJEU= Received: (qmail 57807 invoked by alias); 25 Apr 2018 16:04:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 57688 invoked by uid 89); 25 Apr 2018 16:04:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=iff X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 13/17] y2038: socket: Convert recvmmsg to __kernel_timespec Date: Wed, 25 Apr 2018 18:03:07 +0200 Message-Id: <20180425160311.2718314-14-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:sglwVHXxeSY=:vNscQiXXHEevXWKGq26INQ JlvCBlREy160DQwhPUWb9YmHwtXKjUguqzxLKj5iFVXuua4KbKrB0OFD9F3FxqmdjOoqMfrMj equvKsFysjIEYWngTZlAWR8qK5oAOLYwup6gVx6HhYq/LdxEPkWjjD268zrDspzFoj4yrCOCS 9uoA7tAHoz3IBvkqyFQ7g7Nk4NMwFCkV/eUK3hETxkryhmYHa83GHVSQdmnFvI+T7T6rXLzgd IUj+I0G8zVipJ7bCPPxohsGnPXbc9Otf9bhzw8xgL59xynnK6WV4VtTl+V/9wQMpDZLn0IyQu 0XlK1b18QQDYuk9Hm0Ypn/pPGnbVNWU1LOoNzStl6MvNDNeM6ShlvxnSrdZI5bThO1HOUvfOr 9lJLsl2nxtziFbfH1TwtFxfD5USK3WwyK/THEKylBNFt8HwhVcjH+lq5wTaNLF7D5w3He/GEH suyKD+65UEowYTuxaGAEUSjXt0rK0u7SmekmPP69NsWfw1QrLzGW+HHjzHP10jdnVXzqcjWsy tg71DCyMJa5rBtyrE3z5W09pCGJRjBINNVhBeOzxE3LCU2WOJDaNXrOLWRuQVnUBglbZYwcro LAJczieX1mL6TbXSAtQ2T3kiNeQPbgveo8u5gF7UKPPCN/jZrVAjsHJOmkz8W9hXjIukJqch4 ExNRUtr/p/Dfq/FWCx3Bb3C0+Js0bt/DM/38FcxsAeS32guXjGYZANLHAopOkTeQ/xQg= 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 ea50f4a65816..d36a6c1bdbaf 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -345,7 +345,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 @@ -355,7 +355,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 ffd8674e9df7..eaa32317f573 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -817,7 +817,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 5ae7437d3853..93b80a3d967c 100644 --- a/net/compat.c +++ b/net/compat.c @@ -815,18 +815,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 f10f1d947c78..4510e6269764 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2343,7 +2343,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; @@ -2408,8 +2408,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; @@ -2455,10 +2454,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; @@ -2466,13 +2465,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; @@ -2480,7 +2478,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); } @@ -2603,7 +2601,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,