From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 042B8C43387 for ; Fri, 18 Jan 2019 12:28:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C946820823 for ; Fri, 18 Jan 2019 12:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727558AbfARM2r (ORCPT ); Fri, 18 Jan 2019 07:28:47 -0500 Received: from relay.sw.ru ([185.231.240.75]:56744 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbfARM2r (ORCPT ); Fri, 18 Jan 2019 07:28:47 -0500 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gkTGN-00031a-VF; Fri, 18 Jan 2019 15:28:44 +0300 Subject: Re: [PATCH 1/7] fuse: Check for fc->connected in fuse_dev_alloc() To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org References: <154754701031.4244.8089449938935364463.stgit@localhost.localdomain> <154754755979.4244.14965151684224631403.stgit@localhost.localdomain> From: Kirill Tkhai Message-ID: <98ae21a4-fb96-c06e-e442-5929d36f2bf3@virtuozzo.com> Date: Fri, 18 Jan 2019 15:28:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 18.01.2019 15:07, Miklos Szeredi wrote: > On Tue, Jan 15, 2019 at 11:19 AM Kirill Tkhai wrote: >> >> fuse_dev_alloc() may be called after fc->connected >> is dropped (from ioctl), so here we add sanity check >> for that case. > > AFAICS this is not fixing a bug; i.e. even if the fuse_dev is added to > the fuse_conn's list after disconnection there would be no leak. > > In other words, it's irrelevant whether the connection reset comes > just before the ioctl completes or just after. Or am I missing > something? Yeah, there won't be a leak. The only problem I see, userspace daemon may become waiting in fuse_dev_do_read() after abort is finished. This means fc->count won't be put, and manual killing signal will be needed. I.e., umount -f will wait till the daemon is killed manually. Not so big a problem, but not very pleasant... Kirill >> >> Signed-off-by: Kirill Tkhai >> --- >> fs/fuse/inode.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c >> index 336844d0eb3a..0361a3d62356 100644 >> --- a/fs/fuse/inode.c >> +++ b/fs/fuse/inode.c >> @@ -1054,10 +1054,19 @@ struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc) >> fuse_pqueue_init(&fud->pq); >> >> spin_lock(&fc->lock); >> + if (!fc->connected) { >> + spin_unlock(&fc->lock); >> + goto out_put; >> + } >> list_add_tail(&fud->entry, &fc->devices); >> spin_unlock(&fc->lock); >> >> return fud; >> +out_put: >> + fuse_conn_put(fc); >> + kfree(pq); >> + kfree(fud); >> + return NULL; >> } >> EXPORT_SYMBOL_GPL(fuse_dev_alloc); >> >>