From patchwork Tue Nov 7 14:09:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118171 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4025928qgn; Tue, 7 Nov 2017 06:10:56 -0800 (PST) X-Google-Smtp-Source: ABhQp+RWBVWzpmW9SV7dbia6Vlya+1WfaZRaWVkxt8oWVDNxTdE85H7hJNhTT+LMeqfyDrViN7tr X-Received: by 10.159.195.7 with SMTP id bd7mr18492071plb.366.1510063856603; Tue, 07 Nov 2017 06:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510063856; cv=none; d=google.com; s=arc-20160816; b=N/sO6QJ/FU/VdVXXTjALaCrND5EfRp1sB4o4XnTvXs/zWcQRrdc53Nodj+2RJMs6Rq +f1QYq7TQ7/GmucJFH6ABHXhwwc9EdRerWuoLspDXsEyB9kmPYu5waH0mvxUsdLYg4rw L3QK8QP1vFbmyChSI29Vb56mef9jXgPnx0uyEGDZqyf1DD0fr2EMg2zP+Vl3eFbPICMg 8QieE+v9b2K3R1oAgyrMffExF5cLESDPd1rCQ4xnMrfJFDWIWY4NtsoVVQdLsFbYxOt3 54675jbgy4EOL+hQsLLGtf6SWolPcobVKQyIoU4n3pVT0LZShOwaq+PYcOpyyh/bPmTS 66Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=efrOEZylTgkWkr8Nhq9xPVoCskRoIXm69Bp3YAQexwc=; b=u9jyn+E8VGyn3IE+/rvHll7B/lgsVt+a+qy3XKea/j+wxYfjDDBQOxmzM7o+2Uzf8k bKcm08HmYAxdUkSIaqbERIbHFxTE9NxrwDaRh9/GhDFB+M6QU4sDE7J6U+TBkAsl6dha Nh/hQFOeGyvLTps9c0/oL3fmhfxxoZys+mu1uJBU1CKZvDJFWSKZD2Oa9Bx0WZmZAE25 KIavIKj+OH+azwOvVjERQ9OceqQts57e1Xj0fqhb3HOP5LQ+/qM/9cO2sX2shIAg2E28 nmxtPQZBWWQlqskN3o+AKGmA1ab2XGeZf+vBJs9jWqYYsAlNXiMp2bMwc1t6i2ePCm5g Yu7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 q5si1267075pgp.196.2017.11.07.06.10.56; Tue, 07 Nov 2017 06:10:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934372AbdKGOKy (ORCPT + 26 others); Tue, 7 Nov 2017 09:10:54 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:64408 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932811AbdKGOKw (ORCPT ); Tue, 7 Nov 2017 09:10:52 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0M89Tt-1f6uP33Kq1-00vfZs; Tue, 07 Nov 2017 15:10:40 +0100 From: Arnd Bergmann To: Richard Henderson Cc: Ivan Kokshaysky , Matt Turner , Alexander Viro , y2038@lists.linaro.org, Deepa Dinamani , Arnd Bergmann , stable@vger.kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] alpha: osf_sys.c: fix put_tv32 regression Date: Tue, 7 Nov 2017 15:09:24 +0100 Message-Id: <20171107141029.3160278-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Zf6NKKHC+LRpX0JKvtMPcY+e/PDs60KJG/zT89bYzwb9NbHa1/W Sz6/k7TyXA0Qhl9C+PSaBL4PqK69HfnzY3L903H7RIMaJzr2gVE1YiTbySI/fWTPzKSauIL 9ln/kd7TSRo6w3dMB8TfZz06dSKaRLS76EDxH65PltVXqqCGuJs3zFvvDTUNKjDk0Z9eM/T Nq8+rcm5uxq8F6IG6OL3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:d76qu0YXIvg=:rajfNhRo7N9u/Qjxmj8uRv 5yl96MXilfWFqU/DSaX1onSnqin2tsMQ15pf28oS71foJT9xgnIi8NkZAZSnt/3l/PMixCAHG 6EAyxY888fkA5w3IqaQsfeYDajt/9mQgZRiaX326MkvmF5jHd9/MIew47uuInpoRLZWd5utvd TbOr4o7FiS9fM4J1nYhPsntjYTyhc2GK75rN76FcSlzmcGBJwd5+KiC3DrOqfzs7ebyDHcxmN nHBnPRERdIrnmST60pHdcnKKjg5SSYehr9zFkOTomnzAOxaNulqIIUB/ONRTHE8w3WDZtFnTp 3egyNZjIpC7A/h8QkhF/BEmh9TV0fvI9nWHj/N7uGqTyN2R2VFxP5zkFsfNZZ2Yz989N8k5d4 21N/FzLVdwuDJxwdILhT2H730TVQ4k4nj5s5zeVwFy8ONBvJst4DUDWmt5LI+FnjIY110lS1J /TGyoMvgG9bEia/xx1tbouVJ8xvINKXC8KqGjU2BeeNygT1vnrBqaQLLr7niYk8mTTCr9RrnW dSv82tM9VXDLfKB9MIBJPnZiBeaosMGBfAXcgF/KOKEDZXAygC0r7C/aDkePHeX/c35DdfL1L BsiOAKGUUx3Q3qidOmTETsUiQp26HCVIcTK3fhYrefFWUYKa27LZ7yPDsIc22FtIagPrd0slB J0ha1hoiJGoxnzhbrqeOQsKaj8QZ3B3JzLbljsxCE8jnfFInhNJtnGdhFJISSX/2JomdOrHWy DK6S9hBtvtdZvP1M6xc0LUmxXAZZeDwm8H4HCA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There was a typo in the new version of put_tv32() that caused uninitialized stack data to be written back to user space, rather than writing the actual timeval for the emulation of gettimeofday(), wait4(), usleep_thread() and old_adjtimex(). This fixes it to write the correct data again. Cc: stable@vger.kernel.org Fixes: 1cc6c4635e9f ("osf_sys.c: switch handling of timeval32/itimerval32 to copy_{to,from}_user()") Signed-off-by: Arnd Bergmann --- arch/alpha/kernel/osf_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index ce3a675c0c4b..75a5c35a2067 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -964,8 +964,8 @@ static inline long put_tv32(struct timeval32 __user *o, struct timeval *i) { return copy_to_user(o, &(struct timeval32){ - .tv_sec = o->tv_sec, - .tv_usec = o->tv_usec}, + .tv_sec = i->tv_sec, + .tv_usec = i->tv_usec}, sizeof(struct timeval32)); } From patchwork Tue Nov 7 14:09:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118172 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4026092qgn; Tue, 7 Nov 2017 06:11:04 -0800 (PST) X-Google-Smtp-Source: ABhQp+T79PVQzSS0X5RN34Y5kHIVz9YEa1sA62k42fCFWaTu5mVaHA9g6KLCukaAY+Pe8KcJ4u9D X-Received: by 10.99.95.139 with SMTP id t133mr18573817pgb.448.1510063864252; Tue, 07 Nov 2017 06:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510063864; cv=none; d=google.com; s=arc-20160816; b=LQWZWa/pc58rLclTNvMKHRNS/yoMD8dwIGGSG5RZsqhxjBXi/Ec/Jp02EzmyEPA4AQ KxB99vEavt2I+K83gaqiRISdhJneZbt5DB7VVFSWmlnXsnaraotvlnCo+pwQyyRYFNlL DE7PxTknfZkb9793r0fzowVrjWI3zRCoa312uJcsU3Jut/qzdBIhQLG28INxbnxvBal9 RhWR1aEb5N8AJlNHK0wjuA821W0Sa/Mu6xfTUy8XdrKgKQBuOPycl9ifUnaA1v0UlfE5 CJXhGeWzlyF8PakyhwPoHymVjZCrvktiOQg+yHQtNesJHpgkun3wOyT7yOZ+hOn92QH7 QkOQ== 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=altjx/qe1FNEKCxAptMgdup3b4QN71n6StsyHin7EzU=; b=KDTQcYYaOETA+8nRxEvU8nZoLyGvZ7LuBQdtEHHIw/lRh9GjJWOtoniMe2gVIj1lBm 7iOHP9tulAtaPfiYfHAr6GVTdN61IUadAO/1WR7uAqzIt6zPL80uv/yu0aYzNr1jyiOv 1vL1pWjO0pPgwskVtJOVqCDm6+CbgtcZ44di38OR2i+JXEqrQSeFFxe1jsObN9EHn4S8 GWSttcgSQLeUTA6EaGs7g6bS9bwIp7FfxJikelHDXF2x4CObcJHo1hX2aZe+wi9SbZsA VPcH+aHJQNCGIL8dFdoXf/d0FowJKp3TCh9LrkVA9n02IOqjRnRDkkomOjMiPTTHDyj7 R+Xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 r26si1300519pge.200.2017.11.07.06.11.03; Tue, 07 Nov 2017 06:11:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964924AbdKGOLC (ORCPT + 26 others); Tue, 7 Nov 2017 09:11:02 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:51611 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932811AbdKGOLA (ORCPT ); Tue, 7 Nov 2017 09:11:00 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0M0zHj-1f6MQz3PAN-00v6Ha; Tue, 07 Nov 2017 15:10:54 +0100 From: Arnd Bergmann To: Richard Henderson Cc: Ivan Kokshaysky , Matt Turner , Alexander Viro , y2038@lists.linaro.org, Deepa Dinamani , Arnd Bergmann , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] alpha: osf_sys.c: use timespec64 where appropriate Date: Tue, 7 Nov 2017 15:09:25 +0100 Message-Id: <20171107141029.3160278-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171107141029.3160278-1-arnd@arndb.de> References: <20171107141029.3160278-1-arnd@arndb.de> X-Provags-ID: V03:K0:2kGjGuR2cdQ8oEeDWKm3pkeYYrGpMOc2y7c6izbbo/04PbA2R52 WEtE2zfJ9WvAFv0l7LT4wLbKv53UmmBIBjLh72NU7lrBzn7oMB8tTQHUXen/04A/qJOFfP4 ZOyb6MT85kwslGcSmUxS404mQGKtHRrtJj3KuzPyH5lPwLRfGuvIMZXwowPDt7r+oS7UjL5 Dw+GRj9vRHrRnQgf5191A== X-UI-Out-Filterresults: notjunk:1; V01:K0:u4OlyeV6bw0=:QxC69Etg7qgEV8KqOuIETx 3woasnhIjtOkRbzAdI5+M+jfPOUa8j9RAB3rmVNgarIUSX19OFxOxTt3lohx0uxv9S7W7EogN O/4NCqiaw8ZuCvwxbYl4Op+wwwQoBV14Qhkie4nmqMJ4n9MXn1Reu2j+cM1Ye2PIg28QCBsI5 HhShT/G2yc6FFVW8yvW89Ox82gxZHj6wlKeYq2xNoEGdr8Hi665/4dHgeAPpCMrX0c2Lyjcig VHfu12o4Ti0CKUp/RiXKwvFmHmmZH8oG7PREXbIX8UjCnI2B4AL2OEhFrHsREN8AM7Yu3H1Gd v24LahXzzM8DVsn4tLzroh6SsMbGXmwDFB0Go5/nIoQcE31RC0btzdSsgmj5axNNUVc9/JBiW +rO7tSkBKWW6uZ6Q1ODHFWX+zkkzQ5WdQHO95eRO5Sobc3P1YcaMfv2CycDj0MXhJiLlmgTb0 6wThabDm6mgIGVj0nnrpOsKJJvZ6xZot5p0DGzhpStmh/z9+musE6P5jVZDsHXoVZ8dmm3WZ+ NrLkGvlpwZwvYjteXmIuUq9MasQc1bb3Ej8xkbTKsfajelCaTNol0iOg1n0ZP0kaGvXfn6JI4 2LHckLmAmvhQOU5h8vmXV2mMdCupaMsnlwl7VungoqgT5fuvOy3tT/NEMqeCtHhxCKF1U2ezZ gBM/DJvS3UITx0GY4eXrxet/AmMSMpoufDhjRcAyDGiCG9tgsKlWwxlfAFqnH2xyKihkz3Qlq UzAqKKAF38Aa8KJ1jE1jcnwY4Q++fxu51hagog== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some of the syscall helper functions (do_utimes, poll_select_set_timeout, core_sys_select) have changed over the past year or two to use 'timespec64' pointers rather than 'timespec'. This was fine on alpha, since 64-bit architectures treat the two as the same type. However, I'd like to change that behavior and make 'timespec64' a proper type of its own even on 64-bit architectures, and that will introduce harmless type mismatch warnings here. Also, I'm trying to kill off the do_gettimeofday() helper in favor of ktime_get() and related interfaces throughout the kernel. This changes the get_tv32/put_tv32 helper functions to also take a timespec64 argument rather than timeval, which allows us to simplify some of the syscall helpers a bit and avoid the type warnings. For the moment, wait4 and adjtimex are still better off with the old behavior, so I'm adding a special put_tv_to_tv32() helper for those. Signed-off-by: Arnd Bergmann --- arch/alpha/kernel/osf_sys.c | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) -- 2.9.0 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 75a5c35a2067..6db6ec30c3de 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -950,18 +950,27 @@ struct itimerval32 }; static inline long -get_tv32(struct timeval *o, struct timeval32 __user *i) +get_tv32(struct timespec64 *o, struct timeval32 __user *i) { struct timeval32 tv; if (copy_from_user(&tv, i, sizeof(struct timeval32))) return -EFAULT; o->tv_sec = tv.tv_sec; - o->tv_usec = tv.tv_usec; + o->tv_nsec = tv.tv_usec * NSEC_PER_USEC; return 0; } static inline long -put_tv32(struct timeval32 __user *o, struct timeval *i) +put_tv32(struct timeval32 __user *o, struct timespec64 *i) +{ + return copy_to_user(o, &(struct timeval32){ + .tv_sec = i->tv_sec, + .tv_usec = i->tv_nsec / NSEC_PER_USEC}, + sizeof(struct timeval32)); +} + +static inline long +put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i) { return copy_to_user(o, &(struct timeval32){ .tv_sec = i->tv_sec, @@ -1004,9 +1013,10 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv, struct timezone __user *, tz) { if (tv) { - struct timeval ktv; - do_gettimeofday(&ktv); - if (put_tv32(tv, &ktv)) + struct timespec64 kts; + + ktime_get_ts64(&kts); + if (put_tv32(tv, &kts)) return -EFAULT; } if (tz) { @@ -1019,22 +1029,19 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv, SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv, struct timezone __user *, tz) { - struct timespec64 kts64; - struct timespec kts; + struct timespec64 kts; struct timezone ktz; if (tv) { - if (get_tv32((struct timeval *)&kts, tv)) + if (get_tv32(&kts, tv)) return -EFAULT; - kts.tv_nsec *= 1000; - kts64 = timespec_to_timespec64(kts); } if (tz) { if (copy_from_user(&ktz, tz, sizeof(*tz))) return -EFAULT; } - return do_sys_settimeofday64(tv ? &kts64 : NULL, tz ? &ktz : NULL); + return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL); } asmlinkage long sys_ni_posix_timers(void); @@ -1083,22 +1090,16 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in, SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, struct timeval32 __user *, tvs) { - struct timespec tv[2]; + struct timespec64 tv[2]; if (tvs) { - struct timeval ktvs[2]; - if (get_tv32(&ktvs[0], &tvs[0]) || - get_tv32(&ktvs[1], &tvs[1])) + if (get_tv32(&tv[0], &tvs[0]) || + get_tv32(&tv[1], &tvs[1])) return -EFAULT; - if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 || - ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000) + if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 || + tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000) return -EINVAL; - - tv[0].tv_sec = ktvs[0].tv_sec; - tv[0].tv_nsec = 1000 * ktvs[0].tv_usec; - tv[1].tv_sec = ktvs[1].tv_sec; - tv[1].tv_nsec = 1000 * ktvs[1].tv_usec; } return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0); @@ -1107,19 +1108,18 @@ SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp, fd_set __user *, exp, struct timeval32 __user *, tvp) { - struct timespec end_time, *to = NULL; + struct timespec64 end_time, *to = NULL; if (tvp) { - struct timeval tv; + struct timespec64 tv; to = &end_time; if (get_tv32(&tv, tvp)) return -EFAULT; - if (tv.tv_sec < 0 || tv.tv_usec < 0) + if (tv.tv_sec < 0 || tv.tv_nsec < 0) return -EINVAL; - if (poll_select_set_timeout(to, tv.tv_sec, - tv.tv_usec * NSEC_PER_USEC)) + if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec)) return -EINVAL; } @@ -1192,9 +1192,9 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options, return -EFAULT; if (!ur) return err; - if (put_tv32(&ur->ru_utime, &r.ru_utime)) + if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime)) return -EFAULT; - if (put_tv32(&ur->ru_stime, &r.ru_stime)) + if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime)) return -EFAULT; if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss, sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss))) @@ -1210,18 +1210,18 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options, SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep, struct timeval32 __user *, remain) { - struct timeval tmp; + struct timespec64 tmp; unsigned long ticks; if (get_tv32(&tmp, sleep)) goto fault; - ticks = timeval_to_jiffies(&tmp); + ticks = timespec64_to_jiffies(&tmp); ticks = schedule_timeout_interruptible(ticks); if (remain) { - jiffies_to_timeval(ticks, &tmp); + jiffies_to_timespec64(ticks, &tmp); if (put_tv32(remain, &tmp)) goto fault; } @@ -1280,7 +1280,7 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p) if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) || (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - offsetof(struct timex32, tick))) || - (put_tv32(&txc_p->time, &txc.time))) + (put_tv_to_tv32(&txc_p->time, &txc.time))) return -EFAULT; return ret;