Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp266527ybb; Thu, 28 Mar 2019 02:01:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGeDfLmlCwG/5LcZp1WuIvdtxtpHteoJzga5ThtJFtp8be0QmLnSfMnX6/5q1zro6w/EvA X-Received: by 2002:a63:4146:: with SMTP id o67mr38629319pga.122.1553763708327; Thu, 28 Mar 2019 02:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553763708; cv=none; d=google.com; s=arc-20160816; b=vRj6DzZ1OSvS7Vu5jBF8K0j2RiBEslJ39tBPJQNfvySwgr5IJwPiLaTECrto7lxfSm Kn4vH1nI5XppSd11Rj8u+6zGlzDB9PjWYguwdco+44rGLH+RwMCl4Pm81IW/bpopmVE/ dyKEPgwsAXpbO2uXZ9hqEdRT7b0WH1Pezm4wsznPheDKwyCjTQclNqWWqD6MgFOowKjk EKfArqsbfXOcZBo4S+czk/Nlh3d73AMgnC09SRXAW6ngyZspICo2ocn+ibvajCozZDX7 wJEUEzSjAcxx388ORSi0EwAq0Odt2+b8ATQHN7Rdy3nU3ZQz0aWgO5xpa0rCXHKpgZ0i fIIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=YIr6GBeV4kv4ITILIHRL0x4YcqxxUtgxirP5AzBgIKY=; b=laokzLE2fVYEqGbqJ7n7BjWWjC/ugwB7ax+tdTf9TQTHXmzDviv13rYYpfNv/0BNpG nt5xNtN308Aoy6PmzjGXHlYqXCrcADlLGMBx8DWoxrv0FqevT85LflwsSO8eu7C5whhI cieguE4YHiwNBHoNSXL6R4LUk0BoWZ/xFY/2aVV9UYCiTyZlrXjxZR0gjkMIy3wbnJ6m s4A2O20tuasKfuqFjYGwveoqiD3ug5aDzLd3h2baGLU8yklM26ItcsiNvTN6eFehT4Vk /l3G3nBJX9ouXMixz+efH3tNq8BW6XTYaEeCIDn4/D8GldSJn7Xq29ywXQ6YNOJlbCOL yJRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32si22592476plf.24.2019.03.28.02.01.32; Thu, 28 Mar 2019 02:01:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbfC1JAt (ORCPT + 99 others); Thu, 28 Mar 2019 05:00:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:34010 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725779AbfC1JAs (ORCPT ); Thu, 28 Mar 2019 05:00:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 76184ABCB; Thu, 28 Mar 2019 09:00:46 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7D59F1E424A; Thu, 28 Mar 2019 10:00:45 +0100 (CET) Date: Thu, 28 Mar 2019 10:00:45 +0100 From: Jan Kara To: Al Viro Cc: Jan Kara , Mark Fasheh , Dave Chinner , Linus Torvalds , syzbot , Alexei Starovoitov , Daniel Borkmann , linux-fsdevel , Linux List Kernel Mailing , syzkaller-bugs , Jaegeuk Kim , Joel Becker Subject: Re: KASAN: use-after-free Read in path_lookupat Message-ID: <20190328090045.GA22915@quack2.suse.cz> References: <20190325045744.GK2217@ZenIV.linux.org.uk> <20190325194332.GO2217@ZenIV.linux.org.uk> <20190325224823.GF26298@dastard> <20190325230211.GR2217@ZenIV.linux.org.uk> <20190326041509.GZ2217@ZenIV.linux.org.uk> <20190327165831.GB6742@quack2.suse.cz> <20190327185948.GC2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190327185948.GC2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 27-03-19 18:59:48, Al Viro wrote: > On Wed, Mar 27, 2019 at 05:58:31PM +0100, Jan Kara wrote: > > On Tue 26-03-19 04:15:10, Al Viro wrote: > > > On Mon, Mar 25, 2019 at 08:18:25PM -0700, Mark Fasheh wrote: > > > > > > > Hey Al, > > > > > > > > It's been a while since I've looked at that bit of code but it looks like > > > > Ocfs2 is syncing the inode to disk and disposing of it's memory > > > > representation (which would include the cluster locks held) so that other > > > > nodes get a chance to delete the potentially orphaned inode. In Ocfs2 we > > > > won't delete an inode if it exists in another nodes cache. > > > > > > Wait a sec - what's the reason for forcing that write_inode_now(); why > > > doesn't the normal mechanism work? I'm afraid I still don't get it - > > > we do wait for writeback in evict_inode(), or the local filesystems > > > wouldn't work. > > > > I'm just guessing here but they don't want an inode cached once its last > > dentry goes away (it makes cluster wide synchronization easier for them and > > they do play tricks with cluster lock on dentries). > > Sure, but that's as simple as "return 1 from ->drop_inode()". Right. > > There is some info in > > 513e2dae9422 "ocfs2: flush inode data to disk and free inode when i_count > > becomes zero" which adds this ocfs2_drop_inode() implementation. So when > > the last inode reference is dropped, they want to flush any dirty data to > > disk and evict the inode. But AFAICT they should be fine with flushing the > > inode from their ->evict_inode method. I_FREEING just stops the flusher > > thread from touching the inode but explicit writeback through > > write_inode_now(inode, 1) should go through just fine. > > Umm... Why is that write_inode_now() needed in either place? I agree that > moving it to ->evict_inode() ought to be safe, but what makes it necessary > in the first place? Put it another way, what dirties the data and/or > metadata without marking it dirty? Well, the inode & pages are marked dirty and they are dirty when we get to iput_final(). But if ->drop_inode() returns 1 (which normally happens only for unlinked files), we will not write out the inode in iput_final() and the dirty data just gets discarded in ->evict_inode(). OCFS2 doesn't want this so they have to write-out by hand. Honza -- Jan Kara SUSE Labs, CR