From patchwork Fri Dec 7 21:18:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153213 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp981890ljp; Fri, 7 Dec 2018 13:18:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/UO1TKJEn2Opcqycm86tFUFQeMtqZ2yrRqKup0hVuCAqaJaAcUYe0WEbpInctjjihYqV39N X-Received: by 2002:a63:334a:: with SMTP id z71mr3383243pgz.400.1544217509644; Fri, 07 Dec 2018 13:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544217509; cv=none; d=google.com; s=arc-20160816; b=tXUAMZfYcTezpFMCG3oetLTZeylDW1HJZ21IzEdouZGTF0yD2cXxxfw9nbcwA8CC68 TnS8grlbkY8XKDFYX8i4kFQ/zbjvqOpQ73Sd5qsUlXytMt3Rn94+3nnUDcYK4anQ00Ng XLkrnmTJ8g4nO9ychaucH+qbUw3rdU3MjwpLKb0KCCxzuPM8ywGR4W9qfTxCvrvQZ+N4 8c3HZ86plsoJNz66mQCHmwn1NK/8BvFAUsTGqi3PqKffiS8Y45IOLcLyJe4PmMvl/vDR B89axfEJdv88c4z2vLA97EJl6MIGdPkJsdBcwsqAx9YIfu6xzYb60Eb5YewAfKf9frpj nALw== 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; bh=xO26Z/2Cf8MU25iwQ5j/9NRI6TvUg9dgMmllWe0OlyE=; b=dKjU0cpbQiO4MsQ30CTwxvDA5cOg7JjJvRJlB9XSTIqqlTfDL8vqwTszI9R0CpEPUu dsfYMkdLaBBTzoXM9XdT7X9YZKdQ3C4M8OqCIQLZqh1cMPwo7JHYw+PgRMvvMBgWx+Vj eRHSRJxfB4Ldhn5XPWEDRmwhQkqBhHDRF9S2SyqeVr25qmNlshnnzs0MBM9Cmvp9YoPz 2CkRb2NGhLKJ5/GSmmyaKy4RxdcjWSOt8KorCJ06ClDSVwQf58VF46AKWs74jv694Cox 6Ir4ZUTrjfmrKYpPWyFWzuIZhAdlXeKKsQoPOcMPyV0dPbyT1XNEw2pX5hoZpy/vIPNB +Tow== 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 d65si4058380pfc.201.2018.12.07.13.18.29; Fri, 07 Dec 2018 13:18:29 -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 S1726186AbeLGVSV (ORCPT + 31 others); Fri, 7 Dec 2018 16:18:21 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:52417 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeLGVST (ORCPT ); Fri, 7 Dec 2018 16:18:19 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1N6KML-1hXEVe16zZ-016eTl; Fri, 07 Dec 2018 22:18:11 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, Deepa Dinamani , John Stultz , Thomas Gleixner , linux-api@vger.kernel.org, Arnd Bergmann Subject: [PATCH 2/5] y2038: futex: Add support for __kernel_timespec Date: Fri, 7 Dec 2018 22:18:05 +0100 Message-Id: <20181207211808.328719-3-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207211808.328719-1-arnd@arndb.de> References: <20181207211808.328719-1-arnd@arndb.de> X-Provags-ID: V03:K1:7ftGwTPI7nF5tkVyrja5NNO8XIM3pe9wwKW0ivr2EU7CWAR7+sJ HNlClwPMuAFys8UuHBQ8XVzUZPxvyoUwUYSmHgMcm5M2RHVe0Ko0liKUc5Sf6yXL2T1wcl6 +4aUBv0+pmN2/m3i4kS2ikZfyMvprft3rNiGo+FGJVBYc+lcyMApCz1fidszd6Oznu99YG0 iqxpFDS+Kwss9rPv0bPQA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:E5NpT+phjsU=:P4Ju90ZAdT3wAhcNFqTgPF 8kD2ckQI6TG/iR5mudT5GuZolIXK9+Vydv9z4xVuhUrQ14rCGPlCaIcevQe6Sfi+cLyV1aQyU KbkfWQdC1XWX2sSQSRz/hmxBgC7ykqeUwtw/ajywquDNipbQk0h1tvpiP1+UkpD8WCwHdEymg im50plQBOhKRe5jZa11bbiCn5cn+KDkHw1aCCbzHFSb62kqEuiWhGAfXOPECSsYqMUXC+NAvi EXLkO0z9Q9Fpfa7FsehGHpXcbokjy7rGQ2VM8uJzzFVpEe5tACPrc6uyoJccXsjAm1iqez7DC 0kJUp2D2nQ0xMb4R12OhMhpFA0hdrCDi8dIAWXTAtG0YQ0QtSq2Tmj4u4Sg1XWjTL30Th2Uqm kWnVf4SvNzf1gaW4eH1LxjDFSpi2cPzuA1PxzTHuPlH/35orgXjiuYywwLowMpaAoYReEU6FQ A/Wswtkj1FY5FdT7j3nwu9B+hND9PqN9DkjDvQjGPvuUKitH+xRsLSWQGZiA0G7b0NtYxC1V9 nAhkLiGbZZHbnTsQnouMs3nui/lv2I0Udps21cNfMIRenbD+bncNj/i0dMHNZhgoox67Q2jUz 1z97Fzgq95IcbXlZzxg8D2V2AaF3uGBnuwiky/x5+Prk+N6Iy5Q8UcO7yRnTPP+HyUdcYr6cp UiCdB/uxYPWJi6H0o1AuBzRfbsmaEJYeyAlGjDxfEwm03WUvADluCg+5vGa7UBZmNVZ+R8T/C kTzF43/O01HePHZT2rrAb20Wr5lKKfPUPET2WA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This prepares sys_futex for y2038 safe calling: the native syscall is changed to receive a __kernel_timespec argument, which will be switched to 64-bit time_t in the future. All the internal time handling gets changed to timespec64, and the compat_sys_futex entry point is moved under the CONFIG_COMPAT_32BIT_TIME check to provide compatibility for existing 32-bit architectures. Signed-off-by: Arnd Bergmann --- include/linux/syscalls.h | 2 +- kernel/futex.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) -- 2.18.0 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a27cf407de92..247ad9eca955 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -553,7 +553,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags); /* kernel/futex.c */ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val, - struct timespec __user *utime, u32 __user *uaddr2, + struct __kernel_timespec __user *utime, u32 __user *uaddr2, u32 val3); asmlinkage long sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, diff --git a/kernel/futex.c b/kernel/futex.c index 5cc7c3b098e9..b305beaab739 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3558,10 +3558,10 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, - struct timespec __user *, utime, u32 __user *, uaddr2, + struct __kernel_timespec __user *, utime, u32 __user *, uaddr2, u32, val3) { - struct timespec ts; + struct timespec64 ts; ktime_t t, *tp = NULL; u32 val2 = 0; int cmd = op & FUTEX_CMD_MASK; @@ -3571,12 +3571,12 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, cmd == FUTEX_WAIT_REQUEUE_PI)) { if (unlikely(should_fail_futex(!(op & FUTEX_PRIVATE_FLAG)))) return -EFAULT; - if (copy_from_user(&ts, utime, sizeof(ts)) != 0) + if (get_timespec64(&ts, utime)) return -EFAULT; - if (!timespec_valid(&ts)) + if (!timespec64_valid(&ts)) return -EINVAL; - t = timespec_to_ktime(ts); + t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); tp = &t; @@ -3747,12 +3747,14 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid, return ret; } +#endif /* CONFIG_COMPAT */ +#ifdef CONFIG_COMPAT_32BIT_TIME COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, struct old_timespec32 __user *, utime, u32 __user *, uaddr2, u32, val3) { - struct timespec ts; + struct timespec64 ts; ktime_t t, *tp = NULL; int val2 = 0; int cmd = op & FUTEX_CMD_MASK; @@ -3760,12 +3762,12 @@ COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || cmd == FUTEX_WAIT_BITSET || cmd == FUTEX_WAIT_REQUEUE_PI)) { - if (compat_get_timespec(&ts, utime)) + if (get_old_timespec32(&ts, utime)) return -EFAULT; - if (!timespec_valid(&ts)) + if (!timespec64_valid(&ts)) return -EINVAL; - t = timespec_to_ktime(ts); + t = timespec64_to_ktime(ts); if (cmd == FUTEX_WAIT) t = ktime_add_safe(ktime_get(), t); tp = &t; @@ -3776,7 +3778,7 @@ COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); } -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_COMPAT_32BIT_TIME */ static void __init futex_detect_cmpxchg(void) {