linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] aio: make sure the input "timeout" value is valid
@ 2017-12-13 13:42 Zhen Lei
  2017-12-13 14:11 ` Matthew Wilcox
  0 siblings, 1 reply; 11+ messages in thread
From: Zhen Lei @ 2017-12-13 13:42 UTC (permalink / raw)
  To: Alexander Viro, Benjamin LaHaise, linux-fsdevel, linux-aio, linux-kernel
  Cc: Tianhong Ding, Hanjun Guo, Libin, Kefeng Wang, Zhen Lei

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@huawei.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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-03-27  4:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 13:42 [PATCH 1/1] aio: make sure the input "timeout" value is valid Zhen Lei
2017-12-13 14:11 ` Matthew Wilcox
2017-12-13 15:58   ` Benjamin LaHaise
2017-12-13 16:27   ` Jeff Moyer
2017-12-13 19:31     ` Matthew Wilcox
2017-12-14  3:18       ` Leizhen (ThunderTown)
2018-01-02 14:51         ` Matthew Wilcox
2018-01-12 19:49           ` Jeff Moyer
2018-03-26 20:01             ` Arnd Bergmann
2018-03-26 21:55               ` Matthew Wilcox
2018-03-27  4:43                 ` Deepa Dinamani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).