Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2718698pxv; Sun, 11 Jul 2021 23:43:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwizkZFZ1qZa8J9+lzHXFNryhnyd1XLuAxtjv1+i7BsiUgglD9tUayiKTHy2Lm7IcxJVt+1 X-Received: by 2002:a17:906:f104:: with SMTP id gv4mr3973867ejb.193.1626072197875; Sun, 11 Jul 2021 23:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072197; cv=none; d=google.com; s=arc-20160816; b=syJIJK+8cBhCmqHJfN3k1nLqHEiKtX4mop2V06ohjg8++B9pT1IMuRnPvCkSSw5p2o sLmlJ05u8HfCZgTVlMD795TL5msk8Ock1tpbUGoiUedhmr+RO0qv+mfRHQ+lPKQR/mWs ptJGPidcEykyVRI/k85lCGI8YLhTUhG0VeS7sKX+yPf189tUGjL226B8hBBGXkIwIhTI IZR3XylsHGBQ/bX4i4n8mxTgvOD2db1EbUAJdOzP2J+6V+MOh37fYnz0vl6i4AVJUG+D hyIy2DjFHaKxPX743uto434tOAmFyFsECrzw47ZTQaZ2mKGn1kEdOd7D+8xjwuEhj39w K1RQ== 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=uv2YhSmp9XYHUSl/ZEAOyLnp0pnqnBTjUfws1tzG0OU=; b=b9i5u2WMsfumhHOos/WG20O44eK7ZsheEVH7NzLjnnmXLRlqdDKmdjTVOEJr3xFige 2Uodhy6wz3u1mloIPk7twBs8m+l50yIN4/3nCCzH50Z/MRrZohis39UUv0eNv1caS90Q BeKDlD0Cd66J+u9aHwmNLFATfMW6CQLIM/HOxE5m/RbWgQmZiOPUK/W8NyVW1ums0Hrf 9yPiwN4xo7tlUNxzuMEyR9zo6bvgvkVLCAKwvLeC/eFgW4NqiGXSCtNByvaAgeDhxCcX xuzpA6ehqN5OeBrTiqms0DZjxJqR5bFKjoqkl2GfV0sZkqYk0X9+xMHjsddj+Z41ryoo ZB0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2KUrWQI0; 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 r6si12101591edo.365.2021.07.11.23.42.55; Sun, 11 Jul 2021 23:43:17 -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=2KUrWQI0; 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 S238535AbhGLGoG (ORCPT + 99 others); Mon, 12 Jul 2021 02:44:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:55158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237804AbhGLGex (ORCPT ); Mon, 12 Jul 2021 02:34:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50F5C610D1; Mon, 12 Jul 2021 06:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071496; bh=g39a+9144TT9EJR5P0Pu/0vGnFAWftgmV3cV/o7Hmro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2KUrWQI0HSf5ad6PilJcXCygn2F1iWyGigU5vRz4nVRIsJjcO1HasiyNZTdQavdYZ 5yE5w5U7t815h/1AlofGxn6uYACg/UKa2MQP1qn7rk/vWIHj4u719fP1cMeesMmK6l BYCOzQG+iUgW0fdUQhqcbaXt9zCYwcQdCXr6UycM= 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.10 094/593] fuse: Fix crash if superblock of submount gets killed early Date: Mon, 12 Jul 2021 08:04:14 +0200 Message-Id: <20210712060853.549495636@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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 e3a43f2a95393000778f8f302d48795add2fc4a8 upstream. As soon as fuse_dentry_automount() does up_write(&sb->s_umount), the superblock can theoretically be killed. If this happens before the submount was added to the &fc->mounts list, fuse_mount_remove() later crashes in list_del_init() because it assumes the submount to be already there. Add the submount before dropping sb->s_umount to fix the inconsistency. It is okay to nest fc->killsb under sb->s_umount, we already do this on the ->kill_sb() path. Signed-off-by: Greg Kurz Fixes: bf109c64040f ("fuse: implement crossmounts") Cc: stable@vger.kernel.org # v5.10+ Reviewed-by: Max Reitz Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -347,15 +347,15 @@ static struct vfsmount *fuse_dentry_auto goto out_put_sb; } + down_write(&fc->killsb); + list_add_tail(&fm->fc_entry, &fc->mounts); + up_write(&fc->killsb); + sb->s_flags |= SB_ACTIVE; fsc->root = dget(sb->s_root); /* We are done configuring the superblock, so unlock it */ up_write(&sb->s_umount); - down_write(&fc->killsb); - list_add_tail(&fm->fc_entry, &fc->mounts); - up_write(&fc->killsb); - /* Create the submount */ mnt = vfs_create_mount(fsc); if (IS_ERR(mnt)) {