Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1303692

Re: int overflow in io_getevents

From Benjamin LaHaise <bcrl@kvack.org>
Newsgroups linux.kernel
Subject Re: int overflow in io_getevents
Date 2016-01-07 17:00 +0100
Message-ID <qOl8K-1I5-5@gated-at.bofh.it> (permalink)
References (2 earlier) <qGp9w-5n4-21@gated-at.bofh.it> <qO0QG-4Ih-15@gated-at.bofh.it> <qOeTF-65o-37@gated-at.bofh.it> <qOkPn-1zT-3@gated-at.bofh.it> <qOkPo-1zT-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Jan 07, 2016 at 04:37:43PM +0100, Dmitry Vyukov wrote:
> pass ts to the function

Yeah, I should have had my morning coffee before hitting send.  Updated 
below, and hopefully final.  Checked with a test program to confirm that 
the huge value of seconds in timespec correctly waits, and that negative 
or other invalid values fail with EINVAL (download from
http://www.kvack.org/~bcrl/aio-io_getevents-timespec.c ).

		-ben
-- 
"Thought is the essence of where you are now."

commit 49b78150bc5762c58cfb8b19a859c354cf1a71ac
Author: Benjamin LaHaise <bcrl@kvack.org>
Date:   Thu Jan 7 10:37:58 2016 -0500

    aio: handle integer overflow in io_getevents() timespec usage
    
    Dmitry Vyukov reported an integer overflow in io_getevents() when
    running a fuzzer.  Upon investigation, the triggers appears to be that
    an invalid value for the tv_sec or tv_nsec was passed in which is not
    handled by timespec_to_ktime().  This patch fixes that by making
    io_getevents() return -EINVAL when timespec_valid() checks fail.  We
    use timespec_valid() instead of timespec_valid_strict() to avoid issues
    caused by userspace not knowing the cutoff for KTIME_SEC_MAX.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>

diff --git a/fs/aio.c b/fs/aio.c
index 155f842..e0d5398 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1269,6 +1269,8 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr,
 
 		if (unlikely(copy_from_user(&ts, timeout, sizeof(ts))))
 			return -EFAULT;
+		if (!timespec_valid(&ts))
+			return -EINVAL;
 
 		until = timespec_to_ktime(ts);
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: int overflow in io_getevents Benjamin LaHaise <bcrl@kvack.org> - 2016-01-06 19:20 +0100
  Re: int overflow in io_getevents Dmitry Vyukov <dvyukov@google.com> - 2016-01-07 10:20 +0100
    Re: int overflow in io_getevents Benjamin LaHaise <bcrl@kvack.org> - 2016-01-07 16:40 +0100
      Re: int overflow in io_getevents Dmitry Vyukov <dvyukov@google.com> - 2016-01-07 16:40 +0100
        Re: int overflow in io_getevents Benjamin LaHaise <bcrl@kvack.org> - 2016-01-07 17:00 +0100
          Re: int overflow in io_getevents Dmitry Vyukov <dvyukov@google.com> - 2016-01-07 17:30 +0100

csiph-web