From patchwork Thu Jan 7 15:52:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin LaHaise X-Patchwork-Id: 7978271 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C38C9F716 for ; Thu, 7 Jan 2016 15:53:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7FB8120142 for ; Thu, 7 Jan 2016 15:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4A0820103 for ; Thu, 7 Jan 2016 15:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcAGPwg (ORCPT ); Thu, 7 Jan 2016 10:52:36 -0500 Received: from kanga.kvack.org ([205.233.56.17]:33257 "EHLO kanga.kvack.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752283AbcAGPwf (ORCPT ); Thu, 7 Jan 2016 10:52:35 -0500 Received: by kanga.kvack.org (Postfix, from userid 63042) id 00779828DE; Thu, 7 Jan 2016 10:52:34 -0500 (EST) Date: Thu, 7 Jan 2016 10:52:34 -0500 From: Benjamin LaHaise To: Dmitry Vyukov Cc: Jan Kara , Alexander Viro , linux-aio , "linux-fsdevel@vger.kernel.org" , LKML , syzkaller , Kostya Serebryany , Alexander Potapenko , Sasha Levin , Andrey Ryabinin Subject: Re: int overflow in io_getevents Message-ID: <20160107155234.GM4439@kvack.org> References: <20151216125618.GA16918@quack.suse.cz> <20160106180158.GE4439@kvack.org> <20160107153132.GL4439@kvack.org> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Dmitry Vyukov 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); }