From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:42256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932998AbcJQSTu (ORCPT ); Mon, 17 Oct 2016 14:19:50 -0400 From: Jeff Moyer To: Christoph Hellwig Cc: viro@zeniv.linux.org.uk, jack@suse.cz, dmonakhov@openvz.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes) References: <1476597082-15317-1-git-send-email-hch@lst.de> Date: Mon, 17 Oct 2016 14:19:47 -0400 In-Reply-To: <1476597082-15317-1-git-send-email-hch@lst.de> (Christoph Hellwig's message of "Sun, 16 Oct 2016 07:51:22 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, Christoph, Christoph Hellwig writes: > diff --git a/fs/aio.c b/fs/aio.c > index 1157e13..bf315cd 100644 > --- a/fs/aio.c > +++ b/fs/aio.c > @@ -1078,6 +1078,17 @@ static void aio_complete(struct kiocb *kiocb, long res, long res2) > unsigned tail, pos, head; > unsigned long flags; > > + if (kiocb->ki_flags & IOCB_WRITE) { > + struct file *file = kiocb->ki_filp; > + > + /* > + * Tell lockdep we inherited freeze protection from submission > + * thread. > + */ > + __sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE); > + file_end_write(file); This ends up being a call to __sb_end_write: void __sb_end_write(struct super_block *sb, int level) { percpu_up_read(sb->s_writers.rw_sem + level-1); } Nothing guarantees that submission and completion happen on the same CPU. Is this safe? -Jeff