From: Greg Kroah-Hartman Date: Mon, 9 Jan 2023 12:50:45 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v5.15.87~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f8a51031944e9038f8061d14c1510eb7ee67850;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: cifs-fix-interface-count-calculation-during-refresh.patch cifs-refcount-only-the-selected-iface-during-interface-update.patch --- diff --git a/queue-6.1/cifs-fix-interface-count-calculation-during-refresh.patch b/queue-6.1/cifs-fix-interface-count-calculation-during-refresh.patch new file mode 100644 index 00000000000..cd527fd1a73 --- /dev/null +++ b/queue-6.1/cifs-fix-interface-count-calculation-during-refresh.patch @@ -0,0 +1,52 @@ +From cc7d79d4fad6a4eab3f88c4bb237de72be4478f1 Mon Sep 17 00:00:00 2001 +From: Shyam Prasad N +Date: Thu, 22 Dec 2022 12:54:44 +0000 +Subject: cifs: fix interface count calculation during refresh + +From: Shyam Prasad N + +commit cc7d79d4fad6a4eab3f88c4bb237de72be4478f1 upstream. + +The last fix to iface_count did fix the overcounting issue. +However, during each refresh, we could end up undercounting +the iface_count, if a match was found. + +Fixing this by doing increments and decrements instead of +setting it to 0 before each parsing of server interfaces. + +Fixes: 096bbeec7bd6 ("smb3: interface count displayed incorrectly") +Cc: stable@vger.kernel.org # 6.1 +Signed-off-by: Shyam Prasad N +Reviewed-by: Paulo Alcantara (SUSE) +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/smb2ops.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/cifs/smb2ops.c ++++ b/fs/cifs/smb2ops.c +@@ -530,7 +530,6 @@ parse_server_interfaces(struct network_i + 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 +@@ -540,6 +539,7 @@ parse_server_interfaces(struct network_i + iface_head) { + iface->is_active = 0; + kref_put(&iface->refcount, release_iface); ++ ses->iface_count--; + } + spin_unlock(&ses->iface_lock); + +@@ -618,6 +618,7 @@ parse_server_interfaces(struct network_i + /* just get a ref so that it doesn't get picked/freed */ + iface->is_active = 1; + kref_get(&iface->refcount); ++ ses->iface_count++; + spin_unlock(&ses->iface_lock); + goto next_iface; + } else if (ret < 0) { diff --git a/queue-6.1/cifs-refcount-only-the-selected-iface-during-interface-update.patch b/queue-6.1/cifs-refcount-only-the-selected-iface-during-interface-update.patch new file mode 100644 index 00000000000..cb4145e7365 --- /dev/null +++ b/queue-6.1/cifs-refcount-only-the-selected-iface-during-interface-update.patch @@ -0,0 +1,41 @@ +From 7246210ecdd0cda97fa3e3bb15c32c6c2d9a23b5 Mon Sep 17 00:00:00 2001 +From: Shyam Prasad N +Date: Tue, 27 Dec 2022 11:29:28 +0000 +Subject: cifs: refcount only the selected iface during interface update + +From: Shyam Prasad N + +commit 7246210ecdd0cda97fa3e3bb15c32c6c2d9a23b5 upstream. + +When the server interface for a channel is not active anymore, +we have the logic to select an alternative interface. However +this was not breaking out of the loop as soon as a new alternative +was found. As a result, some interfaces may get refcounted unintentionally. + +There was also a bug in checking if we found an alternate iface. +Fixed that too. + +Fixes: b54034a73baf ("cifs: during reconnect, update interface if necessary") +Cc: stable@vger.kernel.org # 5.19+ +Signed-off-by: Shyam Prasad N +Reviewed-by: Paulo Alcantara (SUSE) +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/sess.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/cifs/sess.c ++++ b/fs/cifs/sess.c +@@ -292,9 +292,10 @@ cifs_chan_update_iface(struct cifs_ses * + continue; + } + kref_get(&iface->refcount); ++ break; + } + +- if (!list_entry_is_head(iface, &ses->iface_list, iface_head)) { ++ if (list_entry_is_head(iface, &ses->iface_list, iface_head)) { + rc = 1; + iface = NULL; + cifs_dbg(FYI, "unable to find a suitable iface\n"); diff --git a/queue-6.1/series b/queue-6.1/series index 12a495cf5b3..67ce78e43b3 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -1,2 +1,4 @@ arm-renumber-bits-related-to-_tif_work_mask.patch btrfs-replace-strncpy-with-strscpy.patch +cifs-fix-interface-count-calculation-during-refresh.patch +cifs-refcount-only-the-selected-iface-during-interface-update.patch