From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754076AbcJ3Jop (ORCPT ); Sun, 30 Oct 2016 05:44:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:36509 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753068AbcJ3Jon (ORCPT ); Sun, 30 Oct 2016 05:44:43 -0400 Date: Sun, 30 Oct 2016 10:44:37 +0100 From: Jan Kara To: Linus Torvalds Cc: Al Viro , Christoph Hellwig , Jan Kara , Dmitry Monakhov , Jeff Moyer , linux-fsdevel , linux-aio@kvack.org, Linux Kernel Mailing List , stable Subject: Re: [PATCH] aio: fix a user triggered use after free (and fix freeze protection of aio writes) Message-ID: <20161030094437.GA3225@quack2.suse.cz> References: <1477727070-18806-1-git-send-email-hch@lst.de> <1477727070-18806-2-git-send-email-hch@lst.de> <20161029122451.GQ19539@ZenIV.linux.org.uk> <20161029152017.GA7388@lst.de> <20161029185222.GT19539@ZenIV.linux.org.uk> <20161029191753.GU19539@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 29-10-16 13:09:25, Linus Torvalds wrote: > On Sat, Oct 29, 2016 at 12:17 PM, Al Viro wrote: > > > > AFAICS, the possibility of dropping the last reference to struct file > > before ->write_iter() has returned is fundamentally broken. I might be > > missing something subtle here, but... > > Ok, let's add a get_file(); fput(); around that whole iter call sequence. > > And that's a separate issue from "we should hold the fs freezer lock > around the whole operation". So I think we need both. Yup, these are two separate issues. I'm fine with adding get_file(); fput() around the iter call sequence. Then, when we have struct file available for the whole time ->write_iter runs, I'd prefer to keep the call to fool lockdep where original file_end_write() call was - that gives us proper lockdep coverage for all the code behind iter_op(). The downside is we cannot keep helpers as elegant as you suggested in your patch but I believe it's bearable and worth the additional lockdep coverage. I'll send patches shortly... Honza -- Jan Kara SUSE Labs, CR