Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2826199pxv; Mon, 12 Jul 2021 02:54:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGpzq1YIE4+3lfOe+i+s4oj8w7qYxzC0zFYCQ+P+ccaBh+xVjRkGf/etgzmwpcwtZJGxT3 X-Received: by 2002:a92:6805:: with SMTP id d5mr19576835ilc.286.1626083662520; Mon, 12 Jul 2021 02:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083662; cv=none; d=google.com; s=arc-20160816; b=pUaKjk0GufyC0vmYJRb7qVbfpslfmb1RjSqm4BS4LohoumdcnkRnBizzW9LvbzsQqM jVqOTVw7eMoEytk6YkEqcEZCczenSL303KYj9TzRmafSyjPSUHKKgFHQn48woKwAgFZI Rd4XDYVjDMdm6nJvLu6YqrSnxOPsFwlaTEf7TQD5wHb8l3mjM0LNav+QE1PB/ScZH3UO J3UqFtSEFXW/u+u854fTYpqdahU946uIMOCsFW88Oa2cQGAcpS5eb39Ba+f41pQ3QBCR HgBU1mcgkeUGgS60dm0GAtb5TRt+LFdmc7ARQoHm9U7VMRoAJ9tFTHnW+pHRq5vk+agk sZAQ== 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=g7I0sZdLtYzOLyRIbAyIYFe4S7O5w3MA1fO5NJzOHG8=; b=MU3ePLKK7Ox39cnz5KPpMvHuv8dyOweSfU3Jy6qB8qma3e68MQgsJxCRzJiavEJ8kj KlO+rvwAoekNL2bzKIk/2lV/lK6ipDPN/dvV64c0SVT7M4qZRTV3RagDCLQSZ6pnf+Mu NwDDYj0Vr2iS2FmI22eeEbmynxfbFDCBytyH2o5WBWf9RE5bjw3SoyosuFqNg/7Xkun8 xzseWH09iyGlrEIyUO0n1dnz6S8OE7uwhSdE7kBYru5ZLK07+SIVQokAFc+4RXxVxAXG XM3NRUEeNJ/1bQwYKtEIR9ZsyuSD7CRzKQR5UM9n+hxv33IA8MRaVPAftvbpOWHPZaNZ HxUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kdHZtYQu; 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 x9si17780117ill.103.2021.07.12.02.54.11; Mon, 12 Jul 2021 02:54:22 -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=kdHZtYQu; 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 S241344AbhGLGy6 (ORCPT + 99 others); Mon, 12 Jul 2021 02:54:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:34676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238418AbhGLGkM (ORCPT ); Mon, 12 Jul 2021 02:40:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A05A061006; Mon, 12 Jul 2021 06:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071835; bh=x4q9kmvq9nqyUlYiOSJrp5tB/OT/G8mhZiC8JTjfEGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kdHZtYQuWZAIqQTA5TO3G8Hu7NgQZNw5OheYxGqJDoqV4BvEcK+Kc3NGaYyHV9S/k cjkvbHlaloipJ1P1YIzL5TUJApk3JtnoYB4pdQEl98YYloNWm3poPMEL3BfOeaiVDx thsUrqv9i5EtlII+uJCnEBoyllkaVAEHcd+vj6kU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve French , Sasha Levin Subject: [PATCH 5.10 203/593] cifs: fix missing spinlock around update to ses->status Date: Mon, 12 Jul 2021 08:06:03 +0200 Message-Id: <20210712060905.339334582@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: Steve French [ Upstream commit 0060a4f28a9ef45ae8163c0805e944a2b1546762 ] In the other places where we update ses->status we protect the updates via GlobalMid_Lock. So to be consistent add the same locking around it in cifs_put_smb_ses where it was missing. Addresses-Coverity: 1268904 ("Data race condition") Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/cifsglob.h | 3 ++- fs/cifs/connect.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 248ee81e0151..6599069be690 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -979,7 +979,7 @@ struct cifs_ses { struct mutex session_mutex; struct TCP_Server_Info *server; /* pointer to server info */ int ses_count; /* reference counter */ - enum statusEnum status; + enum statusEnum status; /* updates protected by GlobalMid_Lock */ unsigned overrideSecFlg; /* if non-zero override global sec flags */ char *serverOS; /* name of operating system underlying server */ char *serverNOS; /* name of network operating system of server */ @@ -1863,6 +1863,7 @@ require use of the stronger protocol */ * list operations on pending_mid_q and oplockQ * updates to XID counters, multiplex id and SMB sequence numbers * list operations on global DnotifyReqList + * updates to ses->status * tcp_ses_lock protects: * list operations on tcp and SMB session lists * tcon->open_file_lock protects the list of open files hanging off the tcon diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index aabaebd1535f..fb7088d57e46 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2829,9 +2829,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses) spin_unlock(&cifs_tcp_ses_lock); return; } + spin_unlock(&cifs_tcp_ses_lock); + + spin_lock(&GlobalMid_Lock); if (ses->status == CifsGood) ses->status = CifsExiting; - spin_unlock(&cifs_tcp_ses_lock); + spin_unlock(&GlobalMid_Lock); cifs_free_ipc(ses); -- 2.30.2