Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp970019pxj; Fri, 21 May 2021 03:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXnXOdIrqXS0Wh2SUYr+btPiEBI5VUYrbVdWKP8KD7FLe3hefZS/RWLCD24J/PiXCOmRyP X-Received: by 2002:a05:6638:260e:: with SMTP id m14mr3375337jat.83.1621592993511; Fri, 21 May 2021 03:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621592993; cv=none; d=google.com; s=arc-20160816; b=jfk8+bOUW/M3eyezlAA8dBh7dKE2vCLXnoxDha0XJJVyvdQquYxhaxF+4b4MuV3oqY uzXSSI7cDE87af11S2DBYtmj9Kz+9WXw0vdEVDAeQW2pfYCRZ9BnjT+THTQxUNXz2AhG Yx95+x7qBaXgUxktgpNCfYL/jY4e0Tz4MwFnbvFntT+uuDtak8l7xwWfGyh1fxnP4nut JVlvyTpkzBpkSax8iHmr5bKtN/FarDaDQpT5+FZYgEL6hgyceGyvsJI09upLuHNRprsl 6VHAwzztJ8lPdYQn//pvZOr3iapBTdhzem1r+ty9CavLrkl2ImQHGpUYne1DTKDSKVYN rUxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=wbZHHq9v+ut9EOU/1h/JSudfkZxj1wh+mSck340m4As=; b=fDQ7kNk4HeWvMruaSERXcU17jq0OOVlALUX5gf9izqsp7HwIqXkECVEzFWvmpadDvO JtRG9W2S/YcrwefvYunqdAsBYpq2hrQim/VrtxCwWPUR8e7tUZpe8VjXH5HxfwOw+nQ4 cwphJr4RvuZ9dg4gtFINzBKrDosawN33jUGPqNhBqtvRWRTqigh5QoQ/FtllW8u++yiN DydrRdDRPeUzZid3veBGQk2kN6YDGdSv2OW+ZjXH7gmydk47c+maqixANGBzcW++owGr vnTMXY3VP1DSmI9CVqxCbwlfW6Ua3A/gMKp49l+o3EfjUx08HfDTROQV/W43MiXpHk42 Toog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si5153197jar.93.2021.05.21.03.29.40; Fri, 21 May 2021 03:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230417AbhEUIaX convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 May 2021 04:30:23 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:49092 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbhEUIaW (ORCPT ); Fri, 21 May 2021 04:30:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-IzwURQWAMn2VOcSgFBBl0Q-1; Fri, 21 May 2021 04:28:45 -0400 X-MC-Unique: IzwURQWAMn2VOcSgFBBl0Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B08B48042A8; Fri, 21 May 2021 08:28:44 +0000 (UTC) Received: from bahia.lan (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 610C25D764; Fri, 21 May 2021 08:28:35 +0000 (UTC) Date: Fri, 21 May 2021 10:28:33 +0200 From: Greg Kurz To: Miklos Szeredi Cc: virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs@redhat.com, Stefan Hajnoczi , Max Reitz , Vivek Goyal Subject: Re: [PATCH v4 2/5] fuse: Call vfs_get_tree() for submounts Message-ID: <20210521102833.4a7595b7@bahia.lan> In-Reply-To: References: <20210520154654.1791183-1-groug@kaod.org> <20210520154654.1791183-3-groug@kaod.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 May 2021 10:19:48 +0200 Miklos Szeredi wrote: > On Thu, May 20, 2021 at 05:46:51PM +0200, Greg Kurz wrote: > > We don't set the SB_BORN flag on submounts superblocks. This is wrong > > as these superblocks are then considered as partially constructed or > > dying in the rest of the code and can break some assumptions. > > > > One such case is when you have a virtiofs filesystem and you try to > > mount it again : virtio_fs_get_tree() tries to obtain a superblock > > with sget_fc(). The matching criteria in virtio_fs_test_super() is > > the pointer of the underlying virtiofs device, which is shared by > > the root mount and its submounts. This means that any submount can > > be picked up instead of the root mount. This is itself a bug : > > submounts should be ignored in this case. But, most importantly, it > > then triggers an infinite loop in sget_fc() because it fails to grab > > the superblock (very easy to reproduce). > > > > The only viable solution is to set SB_BORN at some point. This > > must be done with vfs_get_tree() because setting SB_BORN requires > > special care, i.e. a memory barrier for super_cache_count() which > > can check SB_BORN without taking any lock. > > Looks correct, but... > > as an easily backportable and verifiable bugfix I'd still go with the > simple two liner: > > --- a/fs/fuse/dir.c > +++ b/fs/fuse/dir.c > @@ -351,6 +351,9 @@ static struct vfsmount *fuse_dentry_automount(struct path *path) > list_add_tail(&fm->fc_entry, &fc->mounts); > up_write(&fc->killsb); > > + smp_wmb(); > + sb->s_flags |= SB_BORN; > + plus the mandatory comment one must put to justify the need for a memory barrier. > /* Create the submount */ > mnt = vfs_create_mount(fsc); > if (IS_ERR(mnt)) { > > And have this patch be the cleanup. > Fair enough. > Also we need Fixes: and a Cc: stable@... tags on that one. > Oops, I'll add these in the next round. > Thanks, > Miklos