From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756124AbbIBUAM (ORCPT ); Wed, 2 Sep 2015 16:00:12 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:20113 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754927AbbIBUAL (ORCPT ); Wed, 2 Sep 2015 16:00:11 -0400 Message-ID: <55E75545.9090607@oracle.com> Date: Wed, 02 Sep 2015 16:00:05 -0400 From: Sasha Levin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Al Viro , Andrey Ryabinin CC: Chuck Ebbert , linux-fsdevel , LKML Subject: Re: fs: out of bounds on stack in iov_iter_advance References: <55CB5484.6080000@oracle.com> <20150815161338.4ea210ff@as> <55D1A6D4.3080605@gmail.com> <20150819054650.GD18890@ZenIV.linux.org.uk> In-Reply-To: <20150819054650.GD18890@ZenIV.linux.org.uk> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/19/2015 01:46 AM, Al Viro wrote: > On Mon, Aug 17, 2015 at 12:18:12PM +0300, Andrey Ryabinin wrote: > >> This bug is similar to recently found bug in 9p: http://thread.gmane.org/gmane.linux.kernel/1931799/focus=1936542 > > Ow. For those who'd missed that fun: the bug in question had turned out to > be caused by improper reuse of request ids, _not_ in the call chain of > the triggering syscall. > >> if (!retval) { >> struct iov_iter data = *iter; >> retval = mapping->a_ops->direct_IO(iocb, &data, pos); >> } >> >> if (retval > 0) { >> *ppos = pos + retval; >> iov_iter_advance(iter, retval); >> >> >> So either filemap_write_and_wait_range() > Shouldn't - it's supposed to return 0 or -E... > >> or mapping->a_ops->direct_IO() returned more >> than 'count'. > > Was there DAX involved? ->direct_IO() in there is blkdev_direct_IO(), > which takes rather different paths in those cases... I don't think so, at least I didn't configure it in. >>> Also too the file and line number >>> (lib/iov_iter.c:511) are completely useless because of inlining, >>> though that's not kasan's fault. > > Might make sense to slap > if (WARN_ON(size > iov_iter_count(i))) > print size and *i > and see if it triggers... It finally reproduced. size == 0x1000000, iov_iter_count(iter) == 0x1234. Thanks, Sasha