From patchwork Thu Apr 27 03:09:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1774324 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; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=JO+gP0AX; 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 4Q6LLf5Qfsz23vL for ; Thu, 27 Apr 2023 13:09:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242905AbjD0DJ1 (ORCPT ); Wed, 26 Apr 2023 23:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242895AbjD0DJZ (ORCPT ); Wed, 26 Apr 2023 23:09:25 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924F440DA for ; Wed, 26 Apr 2023 20:09:23 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2a8dd1489b0so76919251fa.3 for ; Wed, 26 Apr 2023 20:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682564961; x=1685156961; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=xf+gurgH4g455L2T8b5XNhCtdmfV7A+6I1FsTUYGsi0=; b=JO+gP0AXlZLdtQi5MTNxY90WCF+JhjEwohXf8rLqa6rEheAdq4+UR8ECIun5mwrRKM RQ+r2747TmE8z6WUPMivBwg1I9SJ+VJZX+ntwlh+OjOGumfKJfK1fbTQMLj9RiJT8jNd ilFoOctmuXZ3ZJFNFyiMNmd+oweiLYJjuBjsQd3ZTrMhOGPiP+BUm07E/Ulc80qxuD/h ZTdtSpDgciHtLWAFh9ABGAc5xnV1mSp2d4Tp1jRgGrZVlZgFMEKr5udq0d7fTGce3BLj vHxJ/QyMicSn/FJuEQbdFIBo2hCAg9QMxsnt0QGzSfQevsf9IuwnWIa4Xcc74HZDi3li fsag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682564961; x=1685156961; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xf+gurgH4g455L2T8b5XNhCtdmfV7A+6I1FsTUYGsi0=; b=l0dE3otH2abjLZUoXAnEp4B6sHKqYARAvD3/4/qHiwLaIdBRyWQP0z2yigEh7Mzn2t 6rR/PfBr5qbnZkbEelf3X6iImXW0jSljQL9BThG37KV7IQwTGf2i3lXCLt+VzeBLdgm8 KDmHiIFHplAhLoBU0obUCcC7QEQsDetmbEpgOB02/dYMJo3WraMX8+AGGUYF3PqC+vW7 +ZbAq64nf8OPdRaKush2/Go/o+LnRqY1eYy3bzpZ7UkBFnTnfxpNWIXtH9OM30CSpFKy CxpqNaIfgCNI8FUGahKTJPJ3ZOZ8eIySdGIxqGp+ozPlGwXyQXtwtLNLSIZwmndii7+a wOBA== X-Gm-Message-State: AC+VfDxpTEOLdsUrcGiCoAc5xG58KNdMXZaRW/wnkNFuWCfLxtyQI1mG XQPbxpCimF8SES85cd2kOXxXoWwQL6famnnBU+8YqNlmV5k= X-Google-Smtp-Source: ACHHUZ6I9t4sJOqos8UudO4WLVIPUXtG0QDDReJZBgnl1B1GeP0JUCkE57j718zcGxxIYtrXsi1Sl2QxVTQ7gm6psRM= X-Received: by 2002:ac2:5930:0:b0:4eb:1527:e2a7 with SMTP id v16-20020ac25930000000b004eb1527e2a7mr68250lfi.45.1682564961231; Wed, 26 Apr 2023 20:09:21 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Wed, 26 Apr 2023 22:09:10 -0500 Message-ID: Subject: [PATCH][CIFS] missing lock when updating session status To: CIFS X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-cifs@vger.kernel.org Coverity noted a place where we were not grabbing the ses_lock when setting (and checking) ses_status. Addresses-Coverity: 1536833 ("Data race condition (MISSING_LOCK)") From 390c90c2928a33f2632e9d668cd3b5b769c9b1e9 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 26 Apr 2023 22:01:31 -0500 Subject: [PATCH] cifs: missing lock when updating session status Coverity noted a place where we were not grabbing the ses_lock when setting (and checking) ses_status. Addresses-Coverity: 1536833 ("Data race condition (MISSING_LOCK)") Signed-off-by: Steve French --- fs/cifs/connect.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1cbb90587995..cc538ed61bc0 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1916,19 +1916,22 @@ void cifs_put_smb_ses(struct cifs_ses *ses) /* ses_count can never go negative */ WARN_ON(ses->ses_count < 0); + spin_lock(&ses->ses_lock); if (ses->ses_status == SES_GOOD) ses->ses_status = SES_EXITING; cifs_free_ipc(ses); if (ses->ses_status == SES_EXITING && server->ops->logoff) { + spin_unlock(&ses->ses_lock); xid = get_xid(); rc = server->ops->logoff(xid, ses); if (rc) cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n", __func__, rc); _free_xid(xid); - } + } else + spin_unlock(&ses->ses_lock); spin_lock(&cifs_tcp_ses_lock); list_del_init(&ses->smb_ses_list); -- 2.34.1