[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1564451504-27906-1-git-send-email-yi.zhang@huawei.com>
Date: Tue, 30 Jul 2019 09:51:44 +0800
From: "zhangyi (F)" <yi.zhang@...wei.com>
To: <linux-aio@...ck.org>, <linux-fsdevel@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <bcrl@...ck.org>, <viro@...iv.linux.org.uk>, <jmoyer@...hat.com>,
<arnd@...db.de>, <deepa.kernel@...il.com>, <yi.zhang@...wei.com>,
<wangkefeng.wang@...wei.com>
Subject: [PATCH v2] aio: add timeout validity check for io_[p]getevents
io_[p]getevents syscall should return -EINVAL if timeout is out of
range, add this validity check.
Signed-off-by: zhangyi (F) <yi.zhang@...wei.com>
Reviewed-by: Jeff Moyer <jmoyer@...hat.com>
Cc: Jeff Moyer <jmoyer@...hat.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Deepa Dinamani <deepa.kernel@...il.com>
---
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
Powered by blists - more mailing lists