diff mbox series

New Defects reported by Coverity Scan for linux-next weekly scan

Message ID CAH2r5muQU+e=JxuOQB=SrJAS_bBM-pY0Y7ymPC=n2FrXqTK4XQ@mail.gmail.com
State New
Headers show
Series New Defects reported by Coverity Scan for linux-next weekly scan | expand

Commit Message

Steve French Oct. 17, 2022, 5:16 p.m. UTC
Lightly updated the patch to address the existing missing lock issue
near the same line I changed

See attached

---------- Forwarded message ---------
From: <scan-admin@coverity.com>
Date: Mon, Oct 17, 2022 at 7:04 AM
Subject: New Defects reported by Coverity Scan for linux-next weekly scan
To: <smfrench@gmail.com>


Hi,

Please find the latest report on new defect(s) introduced to
linux-next weekly scan, under component 'FS-CIFS',  found with
Coverity Scan.

1 new defect(s) introduced to linux-next weekly scan, under component
'FS-CIFS',  found with Coverity Scan.
7 defect(s), reported by Coverity Scan earlier, were marked fixed in
the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1526374:  Concurrent data access violations  (MISSING_LOCK)
/fs/cifs/smb2ops.c: 657 in parse_server_interfaces()
diff mbox series

Patch

From 3f825b8fa93bb300e60c932753e8c5274b253a77 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Sat, 15 Oct 2022 17:02:30 -0500
Subject: [PATCH] smb3: interface count displayed incorrectly

The "Server interfaces" count in /proc/fs/cifs/DebugData increases
as the interfaces are requeried, rather than being reset to the new
value.  This could cause a problem if the server disabled
multichannel as the iface_count is checked in try_adding_channels
to see if multichannel still supported.

Also fixes a coverity warning:

Addresses-Coverity: 1526374 ("Concurrent data access violations  (MISSING_LOCK)")
Cc: <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 17b25153cb68..4f53fa012936 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -530,6 +530,7 @@  parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
 	p = buf;
 
 	spin_lock(&ses->iface_lock);
+	ses->iface_count = 0;
 	/*
 	 * Go through iface_list and do kref_put to remove
 	 * any unused ifaces. ifaces in use will be removed
@@ -651,9 +652,9 @@  parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
 			kref_put(&iface->refcount, release_iface);
 		} else
 			list_add_tail(&info->iface_head, &ses->iface_list);
-		spin_unlock(&ses->iface_lock);
 
 		ses->iface_count++;
+		spin_unlock(&ses->iface_lock);
 		ses->iface_last_update = jiffies;
 next_iface:
 		nb_iface++;
-- 
2.34.1