Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4575807imb; Wed, 6 Mar 2019 17:22:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzrJBbPxusDvUo2oBmOZVQESqFSYhMvrrJa0MLnsOcxgfbYZSqm5T2fEe+CDoy130iaJr03 X-Received: by 2002:a62:ee03:: with SMTP id e3mr10409888pfi.241.1551921722139; Wed, 06 Mar 2019 17:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551921722; cv=none; d=google.com; s=arc-20160816; b=mcoMspl6mt+zxeO24GRou3hyiPvFWcHC8JGuDICNNMxkyzUQT5O6yVmIMOgibo1R1f Od1kelQqn3puTVhxLas8UJq69eLMc6o9gVesGHvKNyTcN82Ms3xbBdAJcXNWqtDCfPH2 pc7v6fXdEbFV68Dqf7Zm0Yp3xjffqfeP4iBqV/k7F/TGq3+T0sBQIgL9sjPUStut7e6i 2IdABguB7yvmmOCYAebgBu5TmQ3b48tSWGfZr1vhv1qkC9TxXCYy2o4KhOLe0hbSDGUu +yh05ietvdU8q4+y8lEGMQWR6jhZLej33ukrLWq5yX+cajNIEUlJ7+Yrzid1YGslCLn3 vgIA== 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=xfI9kUfIpNlvye5KhgsckzNLwq7P0/IYsTUHotFW6Yc=; b=h1K8rhLlucsBm7DsAzo64IKDWe3epR1ane+eW1obPlERhdnv5qt87GRcxsT3NfjBJq oymUNP5+NTe8CW2erkkTBtPc7yxTWY4RT/GOgf+PdtKrYj8qoGBjeBtS16kuNMMdBvJ5 ZTnhMSVk3oCKsO5LH/L4nr6yE0zz6vKC3BQvP27XkDhjR38jnKgzj+a2WhpJBSzGPDLL ZEVdTCsu6lc9BuW5EoqJsUNetDIK5VIuOGARmNtX/C+cTsH5h6d6bYC+AiOq03kyMH94 IZiSii2+yAtoQS07c6xyTH+StaJfQwQPcDftMwi1OioaNjcDPmw3ac75gVg4Zc1X6pBj GgyA== 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 u77si3233649pfj.139.2019.03.06.17.21.46; Wed, 06 Mar 2019 17:22:02 -0800 (PST) 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 S1726814AbfCGBUy (ORCPT + 99 others); Wed, 6 Mar 2019 20:20:54 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:41014 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbfCGBUx (ORCPT ); Wed, 6 Mar 2019 20:20:53 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h1hi9-0001bg-4L; Thu, 07 Mar 2019 01:20:37 +0000 Date: Thu, 7 Mar 2019 01:20:37 +0000 From: Al Viro To: Linus Torvalds Cc: Eric Dumazet , David Miller , Jason Baron , kgraul@linux.ibm.com, ktkhai@virtuozzo.com, kyeongdon kim , Linux List Kernel Mailing , Netdev , pabeni@redhat.com, syzkaller-bugs@googlegroups.com, Cong Wang , Christoph Hellwig , zhengbin , bcrl@kvack.org, linux-fsdevel , linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com Subject: Re: [PATCH 1/8] aio: make sure file is pinned Message-ID: <20190307012036.GA2217@ZenIV.linux.org.uk> References: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> <20190307004159.GY2217@ZenIV.linux.org.uk> <20190307004828.GZ2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307004828.GZ2217@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 Thu, Mar 07, 2019 at 12:48:28AM +0000, Al Viro wrote: > On Thu, Mar 07, 2019 at 12:41:59AM +0000, Al Viro wrote: > > On Wed, Mar 06, 2019 at 04:23:04PM -0800, Linus Torvalds wrote: > > > On Wed, Mar 6, 2019 at 4:03 PM Al Viro wrote: > > > > > > > > From: Al Viro > > > > > > > > "aio: remove the extra get_file/fput pair in io_submit_one" was > > > > too optimistic - not dereferencing file pointer after e.g. > > > > ->write_iter() returns is not enough; that reference might've been > > > > the only thing that kept alive objects that are referenced > > > > *before* the method returns. Such as inode, for example... > > > > > > I still; think that this is actually _worse_ than just having the > > > refcount on the req instead. > > > > > > As it is, we have that completely insane "ref can go away from under > > > us", because nothing keeps that around, which then causes all those > > > other crazy issues with "woken" etc garbage. > > > > > > I think we should be able to get rid of those entirely. Make the > > > poll() case just return zero if it has added the entry successfully to > > > poll queue. No need for "woken", no need for all that odd "oh, but > > > now the req might no longer exist". > > > > Not really. Sure, you can get rid of "might no longer exist" > > considerations, but you still need to decide which way do we want to > > handle it. There are 3 cases: > > * it's already taken up; don't put on the list for possible > > cancel, don't call aio_complete(). > > * will eventually be woken up; put on the list for possible > > cancle, don't call aio_complete(). > > * wanted to be on several queues, fortunately not woken up > > yet. Make sure it's gone from queue, return an error. > > * none of the above, and ->poll() has reported what we wanted > > from the very beginning. Remove from queue, call aio_complete(). > > > > You'll need some logics to handle that. I can buy the "if we know > > the req is still alive, we can check if it's still queued instead of > > separate woken flag", but but it won't win you much ;-/ > > If anything, the one good reason for refcount would be the risk that > some ->read_iter() or ->write_iter() will try to dereference iocb > after having decided to return -EIOCBQUEUED and submitted all bios. > I think that doesn't happen, but making sure it doesn't would be > a good argument in favour of that refcount. *grumble* It is a good argument, unfortunately ;-/ Proof that instances do not step into that is rather subtle and won't take much to break. OK... I'll try to massage that series on top of your patch; I still hate the post-vfs_poll() logics in aio_poll() ;-/ Give me about half an hour and I'll have something to post.