Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1393917pxj; Fri, 21 May 2021 13:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGXr4fDvf37NJXwmt7TGtT/uRmtBxJwwMuiHb2dN4pPkz9rHmgDgog37y5McWxZny1wVAm X-Received: by 2002:a6b:f815:: with SMTP id o21mr556539ioh.0.1621627752682; Fri, 21 May 2021 13:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621627752; cv=none; d=google.com; s=arc-20160816; b=nU85NGoYntWo/m1o9ugBq/mxZ1aE38HLKGJSBBaLLsFerOtYhornGT9EhR3gK9PG29 xPleiRt1fx/audUBU2tUMpqRypU+JeOeeYgyaQGdT9MqEVvJXBSTYEK6v9XLViFcYfA3 Lp6pinrSi6RfqPrDCxvBwlaJduvJ91JQZQptXv/sY8OoFLVueu4z7PMeuzE2KMyshlf3 bMlokltLzOJoeGB6gJFkUXJoXhhrEimfP9tJDfg+Lm8RK3x7RppL7giYSEHR4uuS8BAU jxnm/lZfhiOejoN7Uz9fNSCO5wr1h9+7HeJfKsC+8pciPG4SM1tJhnlxUEgP41HvoplB qAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9BT3Hx3P3B8a0YB8xDWcQzYi30cUttNenzj/Q+a2BuE=; b=o/QhjvLlkHXtHlEF0Qa2OX07dRS6P9LQQ471yltN3b0Zs65/qpY3f15WEmkGYgg5Wm AH9NvG0rapka0d4KBGCByk7D9RkG6jW5FMf26CSvY3V2MP4SPu6R5D0eVxBUMY4EMImr gHefcUlYO3OlRjJVFIc8SOAt2dYtGEccBqMhpVHIFFSZfHC6/yVWbarqvt87htbfwS0H QuKmJUiWTTHqbksJfIQA8jER+wcSuLtONbeAmgkeoCpfczvAOtBX1MWNpYl0aGlcT15S bgy4byLUKEriA8h93NIpNN6Ky2iiyAFJyQPvig5Py1F2QvB6qufsXky0vodm/93ingw7 qW6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=ZHFefVH2; 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 c6si7471121iot.35.2021.05.21.13.09.00; Fri, 21 May 2021 13:09:12 -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; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=ZHFefVH2; 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 S230404AbhEUIVS (ORCPT + 99 others); Fri, 21 May 2021 04:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbhEUIVR (ORCPT ); Fri, 21 May 2021 04:21:17 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E78DC061574 for ; Fri, 21 May 2021 01:19:54 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id u21so29155609ejo.13 for ; Fri, 21 May 2021 01:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9BT3Hx3P3B8a0YB8xDWcQzYi30cUttNenzj/Q+a2BuE=; b=ZHFefVH2NnwfN6qqSETR6RWg6qE1d8/n84IVK9M8F1u0akSKx5Q7ErkV1KbVW9x27l 7HFRXFibKZd8ahV6ZQDpItgA6t0mQgPNTf8kbuXC+4bTQW8iIJKVPqXdy3KpKqnIO12q xIxpuQl4VdPbLn0x6bDDouPcKq/civ6NhsluI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9BT3Hx3P3B8a0YB8xDWcQzYi30cUttNenzj/Q+a2BuE=; b=AKLDk8cMfVVYdW3la0bWf/OmLglM28Pi8IgP/UDaLZzLXkZwdkyIkSArHeQg8pLvM1 2lwH1tYBiveRc+uw9rQssfrjJzW3EzTKkIuSYm1XyQ8JfCPOU5BtXqi0vbj10NRsPUnP 7SHX+vv2KZPOi+UFnCyjBGZg3FUfSiSp1jomXC29216IovTfwZMYqKDwv2FmGyc0dC2p 7dLWOgzctrmkVHaD2GGLDfbMg5P3em08xvyOnFFJzy7Gqk/KgVVNANZnyr0Lp/AlLg5Y nW9IxW7hyH4VwwPAGZTIZiNpkhiaH/MH2mg7j345+E+axQw03y4hdodv25alc3J5Lape njig== X-Gm-Message-State: AOAM531k0XOeikIQX7DHDmu4DCr+0XfCFwkuY0spkz3fUecebrzTRCrY rVbL466pnc4EZOtZ3OBeQSQ9Sw== X-Received: by 2002:a17:906:368e:: with SMTP id a14mr9079440ejc.366.1621585191245; Fri, 21 May 2021 01:19:51 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-86-101-169-67.catv.broadband.hu. [86.101.169.67]) by smtp.gmail.com with ESMTPSA id l19sm3373181edv.17.2021.05.21.01.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 01:19:50 -0700 (PDT) Date: Fri, 21 May 2021 10:19:48 +0200 From: Miklos Szeredi To: Greg Kurz 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: References: <20210520154654.1791183-1-groug@kaod.org> <20210520154654.1791183-3-groug@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210520154654.1791183-3-groug@kaod.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + /* Create the submount */ mnt = vfs_create_mount(fsc); if (IS_ERR(mnt)) { And have this patch be the cleanup. Also we need Fixes: and a Cc: stable@... tags on that one. Thanks, Miklos