From patchwork Mon Jul 16 16:10:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142052 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2604470ljj; Mon, 16 Jul 2018 09:12:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMsTkFWwJ4lwUHQeL3XVPtyD4sh/CXn45ZJk//spUvHrFkhzVN1+EnTGPfnkTBGFGxwD4q X-Received: by 2002:a63:3c0c:: with SMTP id j12-v6mr15831509pga.440.1531757545624; Mon, 16 Jul 2018 09:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531757545; cv=none; d=google.com; s=arc-20160816; b=BCQprWUzl04bCWUYYexlmPU725xcKqOHz4nKA8bkNg30fc8ZGhAKc0jjqMJg5vGshC zEqd/jtuBYNkRG3eu02IVfBIXveeLaNFi8mZPR6Qqt+bS4/WGl25BXQYc3oDctgSf4zW x8DUS8VVLQDr0DswAlAEPOz1QyRJvRN+S3yoyLnW6ru+pxpfmRoWhIDFVY4whcRzIByC Zj54SUNmLGtSNQ8AW1isSNu3SA4DoMl1qD5kHvFGqqGmvK/iJk+ThTzpKkFrQcmFrDaO dGOwGBKQE6eEflVn3ZAUsuKvN5BzM9XrqJzk/jhJr+RCh8hddQjsiTrHvALGTZDRS9dG 0zvg== 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=QxNMuqkZ3ovgxhi8bOveNI2F06Gt6inRaUk0Hke4ewQ=; b=W51hYgLgRjRJOqtGVqm+lYcRiTw9tB41NI8N0kKynWrkXGGIQFL9olmuByirLiIzns 3lmVqpB24GUzAwN9V8TP/ACjOa20HdQ1k1ciuAyvbQwZVThRR3EJAfmN0kkW7O3EKMO0 dWHFxDu4OgbKWnvzfvCf4xEQibrdZ65pdSrwB93AhOCHoqUlTk1hF/p25tvVzRR/J4eU zGn345+tRA24e00VVgaCSGR7LkX9LPPbzORmK42Zjw1cPbre4cZsL8u7LFHg6e30oD3W tKeQab6j53au5w4QwxUBcAt/NwS43oobWWxKluATdlNs2qff7s7hivWzliVZHq24l+zn dLQg== 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.25; Mon, 16 Jul 2018 09:12:25 -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 S1731239AbeGPQk3 (ORCPT + 10 others); Mon, 16 Jul 2018 12:40:29 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:41887 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728300AbeGPQkL (ORCPT ); Mon, 16 Jul 2018 12:40:11 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0MKgZn-1fep6e2pol-001wwj; Mon, 16 Jul 2018 18:11:11 +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 10/17] y2038: futex: Add support for __kernel_timespec Date: Mon, 16 Jul 2018 18:10:56 +0200 Message-Id: <20180716161103.16239-11-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:qXNVyDZCrYx+HhRT/7b6IG95YRXh6WE/UB5jbxdkhxM9kyxPquh 0USH2T/mQoyZv2cHtoW2kFdMq9JySnjecnZtlLP7BxT7WOegHw3VqoyAQwRNPPg35edSaI/ eQv9gatltOBeAr4R7FxFz412jU1oZ78qTrMMmOGMKFg6L9782zk3s8gb+PgA9uPaiMoBtA9 XUNB+fw4JjX32zfuBa6SQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:WMH+hWlI/SI=:pCZ57ecD3rJpMoojHmHisU OFvhKnh2XGDp6ILJA+Y4ZUbjB7O4kq8oGeIpPWaDsOQj8Mjw2DDTdQMKCkh17p3lxyknunHHb KZ/dNwZ2Lgo0oIQSAUjLf/NUZmrD9u09zWP2jvEdPrGi3UZb8fGhWrknPGjTxp3mjfS+Um0Rb 3h56vrhjbFrYeOq1lzf+Em5ZhEBQfVYJ8fmeIZ6vjDMaenC7jnUN1f+yqnk5D+tmYaZT3lolq 0eM8dGWx5somRgPZIk9PmQEO75J8alRMVLYOw1/2Tolt9Lm0a4dhk1/NBQ17HwlmtdFBLfvH1 lRVexoNCZjSvK7COLMazowiq6hAVE7lKfhdxEXgmJ35ZwNm9cTHts+uN9xYYLVwnKLWTIoYpj g3UrP2zjbujZMMvxgKu8zE3n8R6K0rACyfy05Rm3R0lQUqk/4RUmTsgBdMhWBc5yV1rtSIh6a YT71yb6G8sgYOo2vSmnub/UJNQGwhwfsw4RqMk+nxcwzV12M/egw7S0hx49VOjy1P64ssMNqA lKkX0AIbK1oZ3lohVhnnjx4wtyRLkG7E8zagkSP/FDxI/m97d7gzESUnBkY5UxTNJJ8aiF/Ol TqteJkvca9B1spThJvIw0Ape5NzkZqxTDs0Xpqf7stoPnmsNo8T8ysK4yseN5hXiBcjzeUcvL RpIstORzoTsZYERs3Q13JLI4lgJUe6Zdr9iJSGv+x/Ozr6poiDazxRCYNq50OidN2RXo= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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.9.0 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 312c248f1fe6..fc98024d3b5e 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -541,7 +541,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 e9013d1e65a1..129555a3b64d 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3556,10 +3556,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; @@ -3569,12 +3569,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; @@ -3745,12 +3745,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 compat_timespec __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; @@ -3758,12 +3760,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 (compat_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; @@ -3774,7 +3776,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) {