From patchwork Mon Sep 30 20:20:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 174797 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7632224ill; Mon, 30 Sep 2019 13:47:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZGmOALK42dP3+TfuPg1+nwgHR8jdCLcq4Ed3jw3nMQaNC0eXSO6qSzOb6K1dX4snT4XVq X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr20198049ejr.294.1569876479071; Mon, 30 Sep 2019 13:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569876479; cv=none; d=google.com; s=arc-20160816; b=eOfsG/dWnd1h/00lX6okGfPpRiMEMIinxzDzHqIIMKhChQBMP3JEb1naqt20WsV2mi OceF61Zcvm1r7x16UUwwP4b0XQ9S/zBkkVvR9j+C389J8aBR1tb8gUhElq+qyHxkxuFt DnBZkLNEFfxKpdz/ughE4CzxE0obYFUVuPlQDc6CBLqCbUC2bbipWGAe1guke61FFlrC yBGSxerDS2ZP952TgZJNeY8g+mZOtuA64WaiSuy34Nz8jP2+KuW9ktVNvMXTB5CXCvW/ 357YgUzHUahnnfchm7W9lWUll8RE2evIH7FKKL9wwTl3onZdhpDkQVdBPfopreh/zklV cCxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0S7BkDW0/wM56FMVIaDSBZDqnkCo5aE1P5CGUCn7z5w=; b=Fyd7nIqxCn/fE+WVcRkjVLZM8ClDpQaiws6A18MPHYwNpK5Mjic5uSFGXZPqsmh1Hr u5t8LUe+x6Gj1j9L5emFMGlqwTS1qSRZPIwradI8jAlveqh5VK8qajlg1sPH9XaHzP5n NHiHL7R746FjHSJgSZDFJg2s+nHNA79zqARjoOFLfxnxcVDzeEMbK4zxECs6CxPFfxEe 7Xmm2GujY1Qq9ZSupe2cbGzVdRljRDP6wambhjA4BlOxo2IpYbZDMslqTG5J1MaVnFyM T9aQg0uVZ4wX7c0L6XVxu8/wfi0SPJ/++p6X2kOMpEaqv0dCHdA95gDXsBEzIbL0DcaT 3fLw== 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 c6si8381160edc.291.2019.09.30.13.47.58; Mon, 30 Sep 2019 13:47:59 -0700 (PDT) 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 S1730143AbfI3Urz (ORCPT + 27 others); Mon, 30 Sep 2019 16:47:55 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:39139 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfI3Urz (ORCPT ); Mon, 30 Sep 2019 16:47:55 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MBUZr-1iQpiz3595-00D3fn; Mon, 30 Sep 2019 22:21:02 +0200 From: Arnd Bergmann To: Jens Axboe Cc: y2038@lists.linaro.org, linux-api@vger.kernel.org, Arnd Bergmann , Alexander Viro , =?utf-8?q?Stefan_B?= =?utf-8?b?w7xobGVy?= , Hannes Reinecke , Jackie Liu , Andrew Morton , Hristo Venev , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] io_uring: use __kernel_timespec in timeout ABI Date: Mon, 30 Sep 2019 22:20:39 +0200 Message-Id: <20190930202055.1748710-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:mlQX66YyJ89UsdNDcTaUDMkvDllD+MCdC0jwrPAhCDuUuJh0vOk zZ1jwySfQ09oEHruJb93xi023HsV+efktaoKqvpmHhP68Y4byhgRSjNpgjGQ3pvTTAS7rFA 09K8xy6PviTkfJyCKQI2+MF+0GZfaZPB8iiYdBkkw2ex2b4niBs+M6FIX3/0Hs4nPJ2Ci+M QEWGo3Z0tATHhXTDBD6Rg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:NV7gpjrMSJA=:okYpni+B9mopWZLlHONDJp xR8Uqy/ksQ9sz7P/lCZkqV1RHmQLWxi3Zcs9hP7G23NVdti21bzURdIU8KTe8KorJ2ZE52kzA JUY4ayZuWOuSN7SGagfzyLt2BJzmrmf/061UoiEHcSTXXZc8d3jsNnx1elf6C7BBJ6ufxKa+7 NGYghSmO7UImkraFvg4CGdj8OK+Gh+82IZhA60bkWtkwNjFgdEJHbvFGGH7JLYUFth9c7+sxx vIb7BtF+63ZinJM6CA02I1FB/BAWQ8cLxI/F6iF5Un4JPbU5306X8Xb0OyVAkRdW52z2jUwsV FoqciNCWCdpZgxclQ4RczL+bc0/UkJxzU0kXQX9stuMQvMoSnDVLPGoismnyM5ukkA2dqPgCK j0fk85HX4KT1XeREo9XqHJrPPPE5XsIlETM58guXXs7H6MOmJFepI4ouGc/CeCybxqQSJeo0r iHrmwdqsvXNCSoyfRKxU+MTNY0P7xASYwJVNF2XRlcQ/BV9dgDjzZs+DRVwcBFwnwuHyIwO3P bP46smitC23t94UHyI7EehWvWuzx6mwwhySFEkX5onBqTcveJ2NyIkgpeTzQ8u4qHu6SSuSES pxQLbTHA+RgF2m6mB5C0EFqCvAmtdF3qlwudBVIABDFAKnSQZ/N2Di0ufu2/aH2RffXW2Yhc2 BeYzdWjHiLQ9BoEPmet/gFeqOPy9L2R0OxZ5ZSD7ICczYGaCZ60Emlm9iZXebCTZVUVwJgHgD kpv9hy/fIGz4pByWEspBJQPhyg+6nRjSCy5lUcp7S1hv2DD5M/1vUHnwY9HPN+PvKEbQM7cnX SXzxqb7MJoSDoOzR0TSTBVMQTcIwZJDTdVt8NzikvdQiyqkcIuxI0UytpsnLgVY1yM/GzlS1B s6w+hxhaCHK4Aws2hZrA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All system calls use struct __kernel_timespec instead of the old struct timespec, but this one was just added with the old-style ABI. Change it now to enforce the use of __kernel_timespec, avoiding ABI confusion and the need for compat handlers on 32-bit architectures. Any user space caller will have to use __kernel_timespec now, but this is unambiguous and works for any C library regardless of the time_t definition. A nicer way to specify the timeout would have been a less ambiguous 64-bit nanosecond value, but I suppose it's too late now to change that as this would impact both 32-bit and 64-bit users. Fixes: 5262f567987d ("io_uring: IORING_OP_TIMEOUT support") Signed-off-by: Arnd Bergmann --- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.0 diff --git a/fs/io_uring.c b/fs/io_uring.c index aa8ac557493c..8a0381f1a43b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1892,15 +1892,15 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe) unsigned count, req_dist, tail_index; struct io_ring_ctx *ctx = req->ctx; struct list_head *entry; - struct timespec ts; + struct timespec64 ts; if (unlikely(ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; if (sqe->flags || sqe->ioprio || sqe->buf_index || sqe->timeout_flags || sqe->len != 1) return -EINVAL; - if (copy_from_user(&ts, (void __user *) (unsigned long) sqe->addr, - sizeof(ts))) + + if (get_timespec64(&ts, u64_to_user_ptr(sqe->addr))) return -EFAULT; /* @@ -1934,7 +1934,7 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe) hrtimer_init(&req->timeout.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); req->timeout.timer.function = io_timeout_fn; - hrtimer_start(&req->timeout.timer, timespec_to_ktime(ts), + hrtimer_start(&req->timeout.timer, timespec64_to_ktime(ts), HRTIMER_MODE_REL); return 0; }