[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1513172572-16724-1-git-send-email-thunder.leizhen@huawei.com>
Date: Wed, 13 Dec 2017 21:42:52 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Benjamin LaHaise <bcrl@...ck.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
linux-aio <linux-aio@...ck.org>,
linux-kernel <linux-kernel@...r.kernel.org>
CC: Tianhong Ding <dingtianhong@...wei.com>,
Hanjun Guo <guohanjun@...wei.com>,
Libin <huawei.libin@...wei.com>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 1/1] aio: make sure the input "timeout" value is valid
Below information is reported by a lower kernel version, and I saw the
problem still exist in current version.
UBSAN: Undefined behaviour in include/linux/ktime.h:55:34
signed integer overflow:
-4971973988617027584 * 1000000000 cannot be represented in type 'long int'
......
[<ffff80000072ca28>] timespec_to_ktime include/linux/ktime.h:55 [inline]
[<ffff80000072ca28>] read_events+0x4c8/0x5d0 fs/aio.c:1269
[<ffff8000007305bc>] SYSC_io_getevents fs/aio.c:1733 [inline]
[<ffff8000007305bc>] SyS_io_getevents+0xd4/0x218 fs/aio.c:1722
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
fs/aio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/aio.c b/fs/aio.c
index a062d75..19f7661 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1858,6 +1858,9 @@ static long do_io_getevents(aio_context_t ctx_id,
if (timeout) {
if (unlikely(get_timespec64(&ts, timeout)))
return -EFAULT;
+
+ if (!timespec64_valid(&ts))
+ return -EINVAL;
}
return do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &ts : NULL);
@@ -1876,6 +1879,8 @@ static long do_io_getevents(aio_context_t ctx_id,
if (compat_get_timespec64(&t, timeout))
return -EFAULT;
+ if (!timespec64_valid(&t))
+ return -EINVAL;
}
return do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &t : NULL);
--
1.8.3
Powered by blists - more mailing lists