Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11061612ybi; Thu, 25 Jul 2019 09:17:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMHkB/jfPLmj+F+D3whn0bMAp71uGfdOhyQV1L/VmFLWdaNirC96231hLRtar/WgUWlkdc X-Received: by 2002:a17:902:b43:: with SMTP id 61mr93875106plq.322.1564071460085; Thu, 25 Jul 2019 09:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564071460; cv=none; d=google.com; s=arc-20160816; b=uxx85hhzG5ZGH2Pdx2bm6Fl1SWBqLhsr1ifv5gO907QIpUO+13T/XvlBAFHfWUJDt2 7eIy/nE4GHmjrfkZC1qFIT56ZoYT2lLMWGnQ0FGqoSwUxHw/sl9aRqtYkwHikcrkd3Rd EDTRyA9ovBAS91D4YdaI5gjb6KktM5iPlBHgYpAev5qc6iAS5nvteX46OGGi2ORbmruL zTn2qNWK5Z5r1biN+sjYa6dUTkrNmr/mMpTsJPyrEPyBud8Z0za56hMnYBrIdrOfOExB b70sXaVCVIU5YNdFFACPwOpqzu9EH99PDsGfmGT3V7cVGvOhyNArB3ahnCGAj6+H9py6 IIpA== 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=PqpNovrQGRrbP+kSp2JCaUb/xayhbrkXgTMAkYT/shY=; b=uRs98+PFuGunqLhx0ryxUL6DTxVqTruRlBMX00IywSWw2O5Oby1hvKzVEcr/CAtg/n 6Bg8cn/M6fJXh5A2VBAL9ivm+/1s1YlZ1OymSB7upLB6qIKXYLVLM8W4m1W9Lf2c6yg7 +AqIZn8WRQv7L86BLhsvP+xAxENyvhz9/JTvhEoCHqANA5HSLJgpc/wLgCcUS6DLaJbz WY9PE22FTXMDsgB65i3zqCEknXodJXnFPW9DNupUq/tyTTZxE6YsY6qlWWJCno//Ge73 jFbJVhrdsW7uLVj1F3eUDt7Gkxh1goUxwD45vHksU7OMggCJYYTm/OH8SXRFhHl6TIRg UsMw== 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 q2si17440544pll.230.2019.07.25.09.17.25; Thu, 25 Jul 2019 09:17: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 S2387780AbfGYHPt (ORCPT + 99 others); Thu, 25 Jul 2019 03:15:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53990 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725808AbfGYHPs (ORCPT ); Thu, 25 Jul 2019 03:15:48 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 72718E9FBD22B4E19D65; Thu, 25 Jul 2019 15:15:45 +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; Thu, 25 Jul 2019 15:15:36 +0800 From: "zhangyi (F)" To: , , CC: , , , Subject: [PATCH] aio: add timeout validity check for io_[p]getevents Date: Thu, 25 Jul 2019 15:21:29 +0800 Message-ID: <1564039289-7672-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 if timeout is out of range, add this validity check. Signed-off-by: zhangyi (F) --- 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