From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbdEIA0i (ORCPT ); Mon, 8 May 2017 20:26:38 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:44950 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbdEIA0h (ORCPT ); Mon, 8 May 2017 20:26:37 -0400 Date: Tue, 9 May 2017 01:26:35 +0100 From: Al Viro To: Shaohua Li Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Kernel-team@fb.com Subject: Re: [PATCH] FS: fix stack-out-of-bounds wanning Message-ID: <20170509002634.GU29622@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 08, 2017 at 04:42:50PM -0700, Shaohua Li wrote: > I'm seeing below with lastet upstream. Commit > 5ecda13(generic_file_read_iter(): make use of iov_iter_revert()) > directly pass iter to ->direct_IO(), ->direct_io already advances count > bytes but return -EIOCBQUEUED. In this case, count is bigger than > iov_iter_count(iter). We really want to revert count - > iov_iter_count(iter) instead of the opposite. Already discussed; the patch in my tree is that braino fix + sanity check in iov_iter_revert(), to prevent anything similar in the future. The reason it wasn't caught in tests (without KASAN, that is) is that to get really obvious breakage out of that, you need a short read from ->direct_IO() *and* fallback to cached read after it. -EIOCBQUEUED obviously excludes the latter, so the bug is almost certain to remain quiet. There is a non-zero chance of actually running into unmapped memory while doing that iov_iter_revert(), but it's fairly low. Unfortunately, since that allowed the damn thing to remain unnoticed... Will be in tonight's pull request.