From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sat, 29 Oct 2016 13:24:51 +0100 From: Al Viro To: Christoph Hellwig Cc: torvalds@linux-foundation.org, jack@suse.cz, dmonakhov@openvz.org, jmoyer@redhat.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] aio: fix a user triggered use after free (and fix freeze protection of aio writes) Message-ID: <20161029122451.GQ19539@ZenIV.linux.org.uk> References: <1477727070-18806-1-git-send-email-hch@lst.de> <1477727070-18806-2-git-send-email-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1477727070-18806-2-git-send-email-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, Oct 29, 2016 at 09:44:29AM +0200, Christoph Hellwig wrote: > - if (rw == WRITE) > + if (rw == WRITE) { > file_start_write(file); > + req->ki_flags |= IOCB_WRITE; > + } > + if (rw == WRITE) { > + /* > + * We release freeze protection in aio_complete(). Fool > + * lockdep by telling it the lock got released so that > + * it doesn't complain about held lock when we return > + * to userspace. > + */ > + __sb_writers_release(file_inode(file)->i_sb, > + SB_FREEZE_WRITE); > + } How about taking this chunk (i.e. telling lockdep that we are not holding this thing) past the iter_op() call, where file_end_write() used to be? As it is, you risk hiding the lock dependencies the current mainline would've caught. Other than that I see no problems with the patch...