From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:37950 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbdJaFAC (ORCPT ); Tue, 31 Oct 2017 01:00:02 -0400 Date: Tue, 31 Oct 2017 05:00:00 +0000 From: Al Viro To: Linus Torvalds Cc: Cong Wang , Andrew Morton , linux-fsdevel , LKML Subject: Re: Kernel crash in free_pipe_info() Message-ID: <20171031050000.GK21978@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Oct 30, 2017 at 08:06:23PM -0700, Linus Torvalds wrote: > We do that "free_pipe_info(inode->i_pipe);", but we never actually > clear inode->i_pipe, so now we have an inode that looks like a pipe > inode, and has a stale pointer to a pipe_inode_info. > > It all looks technically correct. It's fine to use put_filp(), because > the file pointer has never really been used. And the inode should > never get re-used anyway without going through the whole reinit in > inode_init_always(). > > So I don't see anything *wrong*, but I see a lot that is just unusual, FWIW, it's really brittle - consider if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) i_readcount_inc(path->dentry->d_inode); in alloc_file(). It's not the source of trouble in this case, but only because it's the second call that gets FMODE_READ; reorder them in create_pipe_files() and you've got a bug. I considered using fput() there, but that would've required manually decrementing pipe->files first, which made it rather unappealing... I don't see anything relevant there, but that's not saying much - flu and debugging do not mix well, and lack of sleep also doesn't help ;-/