From patchwork Wed Sep 14 04:34:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1677622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=cjr.nz header.i=@cjr.nz header.a=rsa-sha256 header.s=dkim header.b=NJYc8ThZ; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4MS6vr6Cbsz1ynm for ; Wed, 14 Sep 2022 14:35:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbiINEfd (ORCPT ); Wed, 14 Sep 2022 00:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiINEfa (ORCPT ); Wed, 14 Sep 2022 00:35:30 -0400 Received: from mx.cjr.nz (unknown [51.158.111.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AF62ED75 for ; Tue, 13 Sep 2022 21:35:13 -0700 (PDT) Received: from authenticated-user (mx.cjr.nz [51.158.111.142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pc) by mx.cjr.nz (Postfix) with ESMTPSA id C43E1808BF; Wed, 14 Sep 2022 04:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cjr.nz; s=dkim; t=1663130096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CN2EUBcMyX1nfsVRThk56pVChowvIVkzk6cr+aTmTio=; b=NJYc8ThZMJNnqEH/dWbY0TiafuwROpnbpRo5QVc0k2g0ZKw8ipBAw61je2mRHQDiwEkDTZ YxAB8h9Zr8b24cM4J3MO8SA3IzX2szznR4+QWFhtR/FJ3R17GMwWDVbKQcoOmACxGTd6H+ SsrE3l9ZoIjdGhN4Iaf4dN1uZZ/v5571CrzHCh7o2vNK+CPImjpZ7002EIHS2ImBM3jaZZ 11+aw1Ztf01vEzr5pQ0bo4Q6jxkv2Nmdimo4k8hpQQAmUQDA8ORRre7cGdX4UWIdJby7jJ IeOn4fxeQ1SbQcETuveQy2rk6UrAWGjoK5pdJEaOCQgJEvny66PhvNBrHSv1/Q== From: Paulo Alcantara To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH] cifs: add missing spinlock around tcon refcount Date: Tue, 13 Sep 2022 21:34:51 -0700 Message-Id: <20220914043451.18797-1-pc@cjr.nz> MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAY_BE_FORGED,NO_DNS_FOR_FROM,T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR,T_SPF_TEMPERROR autolearn=no 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-cifs@vger.kernel.org Add missing spinlock to protect updates on tcon refcount in cifs_put_tcon(). Fixes: d7d7a66aacd6 ("cifs: avoid use of global locks for high contention data") Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/connect.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 251753d0a54b..23fc48aa2ed6 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2350,7 +2350,9 @@ cifs_put_tcon(struct cifs_tcon *tcon) ses = tcon->ses; cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count); spin_lock(&cifs_tcp_ses_lock); + spin_lock(&tcon->tc_lock); if (--tcon->tc_count > 0) { + spin_unlock(&tcon->tc_lock); spin_unlock(&cifs_tcp_ses_lock); return; } @@ -2359,6 +2361,7 @@ cifs_put_tcon(struct cifs_tcon *tcon) WARN_ON(tcon->tc_count < 0); list_del_init(&tcon->tcon_list); + spin_unlock(&tcon->tc_lock); spin_unlock(&cifs_tcp_ses_lock); /* cancel polling of interfaces */