From patchwork Thu Jun 24 20:33:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1496815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=UxIOD131; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4G9sLD0jflz9sWc for ; Fri, 25 Jun 2021 06:34:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbhFXUg3 (ORCPT ); Thu, 24 Jun 2021 16:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbhFXUg3 (ORCPT ); Thu, 24 Jun 2021 16:36:29 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65ACC061574 for ; Thu, 24 Jun 2021 13:34:08 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id d13so9453901ljg.12 for ; Thu, 24 Jun 2021 13:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=LN6s2yCtRIeJn4no/JRinYyKm3zCu0o0ugOVBzFGoA0=; b=UxIOD131RIWKdcj6ufPWMTYHOxs8HMhJrEka4akD9UQlD9o4cG/lmzqfFVfHWlAz7d mX7az+ryIeeALXThh8Sk8j5XXFrkeP68iqIYLdPLkVSTpMAEkjti+fqKPkod6hIHzunJ ZIlsHC/k7oCbJTSkA6MLQTWy34G+6aEz0vYhpwatbdkhF4RFP4Vyc5eFRjHKIWj8sL8j /d3CnCM9A5aNyn2goIp9tzYlwCeZlWefaenbJfjDyWh3PcqBLCPJouh1K+Ncu9GujMWb Ma3crhqjwp7upBARu0PbU52xotRKysPbnaZI+4XOvLOSrazd0x6BZmg44F1ISYxP7WgS 9CoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=LN6s2yCtRIeJn4no/JRinYyKm3zCu0o0ugOVBzFGoA0=; b=Ziqyr4IDKpJpcuiQCAJO8Mz5LCqIbUeU54jeKhddqOxBCms1Ey2gA3gkEJ3S0pVcAE TLFADMEDFdVyJFuP9aVmdzuqj0q4JMjfquIvB9xqni6gLGL6uJgoBTeKUFVMoJ4s9yH2 lg1/WYdwC2x5zW0hR28BU/dVDUsmEZ+puIJiavkQHZEEz9CFwZ1k2Ddv7xQf/62VbkFi aUeicmvlZLfcOAp16C5ciZ8VybdgLAL8mzhfRWyShajZU4tHGP8X5rnXRaqskKc7Sjdn VEvxMcqVdufDuLjiGC9tJ0LbCU+6LnzXU/XIVCt5mK7S1i7JYqotCtTF28ILaFH5ipqA Vx6w== X-Gm-Message-State: AOAM530ByfaV0UyNl2dl+JAom0d0m03tUHYVs+NrjbcCjY3nejHi6UOP KfBfZgDl18dJQLgSUM0rU8piBFzw0VeiSmRi/YPvtweLSK8TuQ== X-Google-Smtp-Source: ABdhPJz73wigHxHT8QKfOkmroZ0jsRrUTPdFhHKI5PKVObW5sbDuSJyTyeJqknYAHxha3r5bPyhOi/tlIC+gkq4b96c= X-Received: by 2002:a2e:a234:: with SMTP id i20mr5386653ljm.272.1624566846730; Thu, 24 Jun 2021 13:34:06 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 24 Jun 2021 15:33:55 -0500 Message-ID: Subject: [PATCH][CIFS] fix missing spinlock around update to ses->status To: CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 --- fs/cifs/cifsglob.h | 3 ++- fs/cifs/connect.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) From 591071fab232bcde3584ad1fd1ed0f6fdc2fcdb5 Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 24 Jun 2021 15:28:04 -0500 Subject: [PATCH] cifs: fix missing spinlock around update to ses->status 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 --- 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 988346904fd0..fc6b08e5ebbc 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -887,7 +887,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 */ @@ -1785,6 +1785,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 c8079376d294..5d269f583dac 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1598,9 +1598,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