Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp670212pxb; Tue, 5 Apr 2022 18:06:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpaNCzEpjyIXZxMkGMUtiogizbavaWE6kQY1nzmecIARxl9YR+VquaePdalzr9caMM45hI X-Received: by 2002:a17:907:7f0b:b0:6e0:a336:a3f5 with SMTP id qf11-20020a1709077f0b00b006e0a336a3f5mr5618504ejc.541.1649207176174; Tue, 05 Apr 2022 18:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207176; cv=none; d=google.com; s=arc-20160816; b=gwSSrjaJxyKWy036IymYrOWvAQ1GBn8vFbiB2QhiWMsRy57m0z3vLrS86vvvlFGSvC XUzG3g6chJE8z64g6+qnEKvHhLpO/P87lk9+JXXFzHah/RBKxgnfnTFfkNq44BqbCqtJ BsBK2E80KBfuqykn8BTO/BclTyxPehtalX94y5leyXBBdSOWF59OOFkR/N18b0WP2nE8 rYjq1luhlh7uSGXdQsBPv1j3H1qlycRrBajSuhyfySL5VOJgb8n9S8CXCMXQm/5+bDf9 1f3i9dfN3rDeYudwz60lTMGOcw6GmLP/+P8+0rvPdrIl70KDiBfyWu3tpIVHc+q2EvVU 4krQ== 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=purUzmo+pMsCBVgumdkfkUzWsmloplNKZ19WoEudXqc=; b=0GC4I8CTeFj+XIBzaj1KQGOnWU6XLEb/eD2lx5TT6GPsuZvKxy9AwHkot6EJXF5oUO JgGYRmNQwdXmKmlVUQkCBF9yMVzkXrACQgk2wxZ+0/WWiBVvcw2eKX8F+JUn8sPlq439 rlsNlfKRYza2TOPZHtHfj8YNsjsG+CZJSg/HTznqm+a6f+8d54FQgkRZ1kLF+9ouID6O JymBaWosGdpRuyJFwGtAfh7qhmIcUre5T7VYPqxw6Z4R/khlfaQ9EG+oE7bp3y1Itrdf VZxjLboN/Di6B1RXu8tqjaTSUeeEp3k1w3RDPshPUvtbds5j/wfN3qI5/YuKpD1NEeMI siNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nU5NKpLG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a50cf81000000b0041b7bd52e54si10227513edk.294.2022.04.05.18.05.50; Tue, 05 Apr 2022 18:06:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nU5NKpLG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1388160AbiDEOdM (ORCPT + 99 others); Tue, 5 Apr 2022 10:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238890AbiDEJdC (ORCPT ); Tue, 5 Apr 2022 05:33:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4397E22; Tue, 5 Apr 2022 02:20:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8FD88B81B75; Tue, 5 Apr 2022 09:20:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC10BC385A0; Tue, 5 Apr 2022 09:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150429; bh=1VBBbhxbPqgOccqe/3AVFKFROwjjGJwCABhf+k4mAfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nU5NKpLG4r+NYXksfdmBRjHmUzzHpO7CuiEgCiXU/4AxpWqQJzY9MI4U2qBK/mG/e SEwebO80/+i+9JY21+YcVSdjvVJW3ogBB7W5lDdGZHA76GCUuNLonTrrpQM+kfrNfI N1RJ8a1urtQ+6iK66JV8AO+iW72BU6dT/6cuXnJA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , "Paulo Alcantara (SUSE)" , Steve French Subject: [PATCH 5.15 053/913] cifs: fix handlecache and multiuser Date: Tue, 5 Apr 2022 09:18:35 +0200 Message-Id: <20220405070341.410072988@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ronnie Sahlberg commit 47178c7722ac528ea08aa82c3ef9ffa178962d7a upstream. In multiuser each individual user has their own tcon structure for the share and thus their own handle for a cached directory. When we umount such a share we much make sure to release the pinned down dentry for each such tcon and not just the master tcon. Otherwise we will get nasty warnings on umount that dentries are still in use: [ 3459.590047] BUG: Dentry 00000000115c6f41{i=12000000019d95,n=/} still in use\ (2) [unmount of cifs cifs] ... [ 3459.590492] Call Trace: [ 3459.590500] d_walk+0x61/0x2a0 [ 3459.590518] ? shrink_lock_dentry.part.0+0xe0/0xe0 [ 3459.590526] shrink_dcache_for_umount+0x49/0x110 [ 3459.590535] generic_shutdown_super+0x1a/0x110 [ 3459.590542] kill_anon_super+0x14/0x30 [ 3459.590549] cifs_kill_sb+0xf5/0x104 [cifs] [ 3459.590773] deactivate_locked_super+0x36/0xa0 [ 3459.590782] cleanup_mnt+0x131/0x190 [ 3459.590789] task_work_run+0x5c/0x90 [ 3459.590798] exit_to_user_mode_loop+0x151/0x160 [ 3459.590809] exit_to_user_mode_prepare+0x83/0xd0 [ 3459.590818] syscall_exit_to_user_mode+0x12/0x30 [ 3459.590828] do_syscall_64+0x48/0x90 [ 3459.590833] entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Ronnie Sahlberg Acked-by: Paulo Alcantara (SUSE) Cc: stable@vger.kernel.org Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/cifsfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -254,6 +254,9 @@ static void cifs_kill_sb(struct super_bl struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_tcon *tcon; struct cached_fid *cfid; + struct rb_root *root = &cifs_sb->tlink_tree; + struct rb_node *node; + struct tcon_link *tlink; /* * We ned to release all dentries for the cached directories @@ -263,17 +266,21 @@ static void cifs_kill_sb(struct super_bl dput(cifs_sb->root); cifs_sb->root = NULL; } - tcon = cifs_sb_master_tcon(cifs_sb); - if (tcon) { + spin_lock(&cifs_sb->tlink_tree_lock); + node = rb_first(root); + while (node != NULL) { + tlink = rb_entry(node, struct tcon_link, tl_rbnode); + tcon = tlink_tcon(tlink); cfid = &tcon->crfid; mutex_lock(&cfid->fid_mutex); if (cfid->dentry) { - dput(cfid->dentry); cfid->dentry = NULL; } mutex_unlock(&cfid->fid_mutex); + node = rb_next(node); } + spin_unlock(&cifs_sb->tlink_tree_lock); kill_anon_super(sb); cifs_umount(cifs_sb);