Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4190666ybi; Mon, 29 Jul 2019 21:14:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeiMN5DVnr/CUk79rYuGBgrwOrnSqlaDMMzbJ7p6YqWxfuwwQiYy7UiH8/tmsSRiU7eB8P X-Received: by 2002:a63:20d:: with SMTP id 13mr96743967pgc.253.1564460080119; Mon, 29 Jul 2019 21:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564460080; cv=none; d=google.com; s=arc-20160816; b=RNFqxqYrylfgmVa63+xnJhoWbfAvHhWyjANoSN5eVRtLvKFfWOCbpVwapAW8K2hUil 93h0TEt0XhLVjWCSLYr1RJXS/GK8wkM62yeTG0+3+4IunJ3MZA2Fv/+nXY2JAZsqdeMV UZRxGqPlRo82Ynke+iozBLWPEVg5fNTtAkKwlWXmpVTlPiB7xDg1YS0CqCEr2VOsRnpx H+NiYllPCWJsXJm8iQLhSySC0Ua3GLjUSX7pYzP/Engxa0B9SYM2yhlBL5jYgF2LhD8a hDnbOBUt28FJpVcFEq9qO9XUfafaQL5kuLSRIHHrJ5K97Va7+9Qbfo1AXlTX+PVrLxP2 Bg4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=+vkGteMKuM8DiyFA4ZKyZbGVdUVZPdyfjfJYCOwZTVE=; b=S8q9xlalC4UFSZfjymui9E58nFs1wFSC7BjVbbp132zibR1beRFWoHRbEjGXG+GeuB 2nKDJSXzr5zdcmQlM3NehBHH9jgt4W+hUED9pWnXSExF8Z2aLuAAwwlUwrXtZRwkHOmg JrOakUQDdx/zQY8a5nIE5xH6UNrohtXHVSQeWKoxRIjK2GrC9EiVds/imPd+9Jv/Ssxk ll46nweCVZmK+jocx+BKo4X+kI9w4oVRk/fgyakyc/r70GTl7O29lizsUIZ1jgjicMw7 PiGfosIMR4JHiCdaU7nJSud7k7XvVNqjcTUgHVYrI9MuP1belsrXdtivxjA62xDDGOkq BTng== 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 97si28055875ple.161.2019.07.29.21.14.25; Mon, 29 Jul 2019 21:14:40 -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 S1730696AbfG3BqC (ORCPT + 99 others); Mon, 29 Jul 2019 21:46:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3199 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730676AbfG3BqC (ORCPT ); Mon, 29 Jul 2019 21:46:02 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 827B250DC70000F6DD4F; Tue, 30 Jul 2019 09:46:00 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 30 Jul 2019 09:45:50 +0800 From: "zhangyi (F)" To: , , CC: , , , , , , Subject: [PATCH v2] aio: add timeout validity check for io_[p]getevents Date: Tue, 30 Jul 2019 09:51:44 +0800 Message-ID: <1564451504-27906-1-git-send-email-yi.zhang@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org io_[p]getevents syscall should return -EINVAL if timeout is out of range, add this validity check. Signed-off-by: zhangyi (F) Reviewed-by: Jeff Moyer Cc: Jeff Moyer Cc: Arnd Bergmann Cc: Deepa Dinamani --- Changes since v1: - add Reviewed-by and Cc tags. fs/aio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 01e0fb9..dd967a0 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -2031,10 +2031,17 @@ static long do_io_getevents(aio_context_t ctx_id, struct io_event __user *events, struct timespec64 *ts) { - ktime_t until = ts ? timespec64_to_ktime(*ts) : KTIME_MAX; - struct kioctx *ioctx = lookup_ioctx(ctx_id); + ktime_t until = KTIME_MAX; + struct kioctx *ioctx = NULL; long ret = -EINVAL; + if (ts) { + if (!timespec64_valid(ts)) + return ret; + until = timespec64_to_ktime(*ts); + } + + ioctx = lookup_ioctx(ctx_id); if (likely(ioctx)) { if (likely(min_nr <= nr && min_nr >= 0)) ret = read_events(ioctx, min_nr, nr, events, until); -- 2.7.4