Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2833231pxv; Mon, 12 Jul 2021 03:04:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6HPaMv6U3ED33jhgzNvd3H/p43QBA8Xv3qa81NnJJM2xetgaJgfHYqLUygda6KXe7tb6D X-Received: by 2002:a02:cbde:: with SMTP id u30mr25690032jaq.52.1626084291503; Mon, 12 Jul 2021 03:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084291; cv=none; d=google.com; s=arc-20160816; b=ii79lGn7hOIy/BAtoFL+E2B6olWzuELjNJIFq6nTYCnJ6HHwnJHqjworrIGC/Zb27F x78+yRNQkOkKhHQaL59Vi2XNnzsdQCj+/VNKUh+3unhmoJwq2NLFTa3apB/rodKPEt1e mudbkwvXp4dOXjP5KZY9S9anHNHzpaa7kRAUMAgwNWkSkgUH819uR9uBvVAVY6hYml/r oZuVsVHCl/y2OyVZFXDc9uGcBBOE0ZnSMF8DXJinn1vZI0f0RECpLvYcdG4i9nVy658H SXFaqIE68WP2x/FVGd3K4vXcz5je29zravEsjV/uTqeVlylxnIKRq/z0UVABJ0Lb+D/D NAGg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AGy/ZcfgfByWjqG/5543Tt6aOZwU+pCgGkAF+SLXH9w=; b=SRSfA1uJyLbMuBZUXntTjiasRFZqqgBuSZPqnVzWkbuXUrUZNui1v3n0SdUC6OFfcp kEqS2caTiGLCLzx1QyXlcR79AV0p8ysMjiW46SjSCsj5D4WaDRC9760lfMvEE93zqCoK uwRT2+p214qQmMFzDeyjaLK6STMcb+hJ3YFkD7PntEJ6gz8VWNBZ3rTIORANWwxKQzx+ klkPcYzQtI6c8nGb9yi7Ey6asxpsyxVhBQUMqaRVKP+F5IBtN9YWoFMKW/2gKT4sEC8V TANvIAGPNP4l1J35ojrddo2kghuRaORUTtQRbQwDlIJjQ4rlFnR6op1+8WL/MdrEL4gD 5wwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IW1IAqem; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si16627376jai.101.2021.07.12.03.04.39; Mon, 12 Jul 2021 03:04:51 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=IW1IAqem; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244625AbhGLH0x (ORCPT + 99 others); Mon, 12 Jul 2021 03:26:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:35158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239044AbhGLHAg (ORCPT ); Mon, 12 Jul 2021 03:00:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0822B60233; Mon, 12 Jul 2021 06:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073068; bh=or+btZn9+aTZ/4lEwHOGcgaG5cjaF5ouSCshgtB6UeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IW1IAqemiQm00QTs84wLEqiaF8e6yVBQvI3e9/HzEBCcTN9fU6MZQmPaWAtLYFdoz Lzzmk9LSw8GQQ4hTg80fiQMjJ8PDCEdJLLZKcco4rdY78XCv8M5JfPACmV//6mMgDu FXUjoCTOncYqCeno8a1emThXkM9G9inqKeyiinx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Greg Kurz , Max Reitz , Miklos Szeredi Subject: [PATCH 5.12 114/700] fuse: Fix infinite loop in sget_fc() Date: Mon, 12 Jul 2021 08:03:17 +0200 Message-Id: <20210712060941.019322442@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kurz commit e4a9ccdd1c03b3dc58214874399d24331ea0a3ab upstream. We don't set the SB_BORN flag on submounts. 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 with submounts and you try to mount it again : virtio_fs_get_tree() tries to obtain a superblock with sget_fc(). The logic in sget_fc() is to loop until it has either found an existing matching superblock with SB_BORN set or to create a brand new one. It is assumed that a superblock without SB_BORN is transient and the loop is restarted. Forgetting to set SB_BORN on submounts hence causes sget_fc() to retry forever. Setting SB_BORN requires special care, i.e. a write barrier for super_cache_count() which can check SB_BORN without taking any lock. We should call vfs_get_tree() to deal with that but this requires to have a proper ->get_tree() implementation for submounts, which is a bigger piece of work. Go for a simple bug fix in the meatime. Fixes: bf109c64040f ("fuse: implement crossmounts") Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Greg Kurz Reviewed-by: Max Reitz Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dir.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -352,6 +352,17 @@ static struct vfsmount *fuse_dentry_auto sb->s_flags |= SB_ACTIVE; fsc->root = dget(sb->s_root); + + /* + * FIXME: setting SB_BORN requires a write barrier for + * super_cache_count(). We should actually come + * up with a proper ->get_tree() implementation + * for submounts and call vfs_get_tree() to take + * care of the write barrier. + */ + smp_wmb(); + sb->s_flags |= SB_BORN; + /* We are done configuring the superblock, so unlock it */ up_write(&sb->s_umount);