From: Greg Kroah-Hartman Date: Mon, 13 Jun 2022 07:10:58 +0000 (+0200) Subject: 5.18-stable patches X-Git-Tag: v4.9.318~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ebf3d11202f1d9ae7621671bdc382b176a9a085f;p=thirdparty%2Fkernel%2Fstable-queue.git 5.18-stable patches added patches: cifs-fix-reconnect-on-smb3-mount-types.patch cifs-populate-empty-hostnames-for-extra-channels.patch cifs-return-errors-during-session-setup-during-reconnects.patch --- diff --git a/queue-5.18/cifs-fix-reconnect-on-smb3-mount-types.patch b/queue-5.18/cifs-fix-reconnect-on-smb3-mount-types.patch new file mode 100644 index 00000000000..5282b3de6f2 --- /dev/null +++ b/queue-5.18/cifs-fix-reconnect-on-smb3-mount-types.patch @@ -0,0 +1,88 @@ +From c36ee7dab7749f7be21f7a72392744490b2a9a2b Mon Sep 17 00:00:00 2001 +From: Paulo Alcantara +Date: Sun, 5 Jun 2022 19:54:26 -0300 +Subject: cifs: fix reconnect on smb3 mount types + +From: Paulo Alcantara + +commit c36ee7dab7749f7be21f7a72392744490b2a9a2b upstream. + +cifs.ko defines two file system types: cifs & smb3, and +__cifs_get_super() was not including smb3 file system type when +looking up superblocks, therefore failing to reconnect tcons in +cifs_tree_connect(). + +Fix this by calling iterate_supers_type() on both file system types. + +Link: https://lore.kernel.org/r/CAFrh3J9soC36+BVuwHB=g9z_KB5Og2+p2_W+BBoBOZveErz14w@mail.gmail.com +Cc: stable@vger.kernel.org +Tested-by: Satadru Pramanik +Reported-by: Satadru Pramanik +Signed-off-by: Paulo Alcantara (SUSE) +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/cifsfs.c | 2 +- + fs/cifs/cifsfs.h | 2 +- + fs/cifs/misc.c | 27 ++++++++++++++++----------- + 3 files changed, 18 insertions(+), 13 deletions(-) + +--- a/fs/cifs/cifsfs.c ++++ b/fs/cifs/cifsfs.c +@@ -1084,7 +1084,7 @@ struct file_system_type cifs_fs_type = { + }; + MODULE_ALIAS_FS("cifs"); + +-static struct file_system_type smb3_fs_type = { ++struct file_system_type smb3_fs_type = { + .owner = THIS_MODULE, + .name = "smb3", + .init_fs_context = smb3_init_fs_context, +--- a/fs/cifs/cifsfs.h ++++ b/fs/cifs/cifsfs.h +@@ -38,7 +38,7 @@ static inline unsigned long cifs_get_tim + return (unsigned long) dentry->d_fsdata; + } + +-extern struct file_system_type cifs_fs_type; ++extern struct file_system_type cifs_fs_type, smb3_fs_type; + extern const struct address_space_operations cifs_addr_ops; + extern const struct address_space_operations cifs_addr_ops_smallbuf; + +--- a/fs/cifs/misc.c ++++ b/fs/cifs/misc.c +@@ -1209,18 +1209,23 @@ static struct super_block *__cifs_get_su + .data = data, + .sb = NULL, + }; ++ struct file_system_type **fs_type = (struct file_system_type *[]) { ++ &cifs_fs_type, &smb3_fs_type, NULL, ++ }; + +- iterate_supers_type(&cifs_fs_type, f, &sd); +- +- if (!sd.sb) +- return ERR_PTR(-EINVAL); +- /* +- * Grab an active reference in order to prevent automounts (DFS links) +- * of expiring and then freeing up our cifs superblock pointer while +- * we're doing failover. +- */ +- cifs_sb_active(sd.sb); +- return sd.sb; ++ for (; *fs_type; fs_type++) { ++ iterate_supers_type(*fs_type, f, &sd); ++ if (sd.sb) { ++ /* ++ * Grab an active reference in order to prevent automounts (DFS links) ++ * of expiring and then freeing up our cifs superblock pointer while ++ * we're doing failover. ++ */ ++ cifs_sb_active(sd.sb); ++ return sd.sb; ++ } ++ } ++ return ERR_PTR(-EINVAL); + } + + static void __cifs_put_super(struct super_block *sb) diff --git a/queue-5.18/cifs-populate-empty-hostnames-for-extra-channels.patch b/queue-5.18/cifs-populate-empty-hostnames-for-extra-channels.patch new file mode 100644 index 00000000000..bb27f202a89 --- /dev/null +++ b/queue-5.18/cifs-populate-empty-hostnames-for-extra-channels.patch @@ -0,0 +1,54 @@ +From 4c14d7043fede258957d7b01da0cad2d9fe3a205 Mon Sep 17 00:00:00 2001 +From: Shyam Prasad N +Date: Mon, 6 Jun 2022 09:52:46 +0000 +Subject: cifs: populate empty hostnames for extra channels + +From: Shyam Prasad N + +commit 4c14d7043fede258957d7b01da0cad2d9fe3a205 upstream. + +Currently, the secondary channels of a multichannel session +also get hostname populated based on the info in primary channel. +However, this will end up with a wrong resolution of hostname to +IP address during reconnect. + +This change fixes this by not populating hostname info for all +secondary channels. + +Fixes: 5112d80c162f ("cifs: populate server_hostname for extra channels") +Cc: stable@vger.kernel.org +Signed-off-by: Shyam Prasad N +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/connect.c | 4 ++++ + fs/cifs/sess.c | 5 ++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +--- a/fs/cifs/connect.c ++++ b/fs/cifs/connect.c +@@ -97,6 +97,10 @@ static int reconn_set_ipaddr_from_hostna + if (!server->hostname) + return -EINVAL; + ++ /* if server hostname isn't populated, there's nothing to do here */ ++ if (server->hostname[0] == '\0') ++ return 0; ++ + len = strlen(server->hostname) + 3; + + unc = kmalloc(len, GFP_KERNEL); +--- a/fs/cifs/sess.c ++++ b/fs/cifs/sess.c +@@ -274,7 +274,10 @@ cifs_ses_add_channel(struct cifs_sb_info + /* Auth */ + ctx.domainauto = ses->domainAuto; + ctx.domainname = ses->domainName; +- ctx.server_hostname = ses->server->hostname; ++ ++ /* no hostname for extra channels */ ++ ctx.server_hostname = ""; ++ + ctx.username = ses->user_name; + ctx.password = ses->password; + ctx.sectype = ses->sectype; diff --git a/queue-5.18/cifs-return-errors-during-session-setup-during-reconnects.patch b/queue-5.18/cifs-return-errors-during-session-setup-during-reconnects.patch new file mode 100644 index 00000000000..45e62099bc2 --- /dev/null +++ b/queue-5.18/cifs-return-errors-during-session-setup-during-reconnects.patch @@ -0,0 +1,37 @@ +From 8ea21823aa584b55ba4b861307093b78054b0c1b Mon Sep 17 00:00:00 2001 +From: Shyam Prasad N +Date: Tue, 31 May 2022 12:31:05 +0000 +Subject: cifs: return errors during session setup during reconnects + +From: Shyam Prasad N + +commit 8ea21823aa584b55ba4b861307093b78054b0c1b upstream. + +During reconnects, we check the return value from +cifs_negotiate_protocol, and have handlers for both success +and failures. But if that passes, and cifs_setup_session +returns any errors other than -EACCES, we do not handle +that. This fix adds a handler for that, so that we don't +go ahead and try a tree_connect on a failed session. + +Signed-off-by: Shyam Prasad N +Reviewed-by: Enzo Matsumiya +Cc: stable@vger.kernel.org +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/smb2pdu.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/fs/cifs/smb2pdu.c ++++ b/fs/cifs/smb2pdu.c +@@ -288,6 +288,9 @@ smb2_reconnect(__le16 smb2_command, stru + mutex_unlock(&ses->session_mutex); + rc = -EHOSTDOWN; + goto failed; ++ } else if (rc) { ++ mutex_unlock(&ses->session_mutex); ++ goto out; + } + } else { + mutex_unlock(&ses->session_mutex); diff --git a/queue-5.18/series b/queue-5.18/series index 81c6e527ce4..3846213d6aa 100644 --- a/queue-5.18/series +++ b/queue-5.18/series @@ -296,3 +296,6 @@ alsa-usb-audio-set-up-implicit-sync-for-saffire-6.patch alsa-hda-conexant-fix-loopback-issue-with-cx20632.patch alsa-hda-realtek-fix-for-quirk-to-enable-speaker-output-on-the-lenovo-yoga-duetitl-2021.patch alsa-hda-realtek-add-quirk-for-hp-dev-one.patch +cifs-return-errors-during-session-setup-during-reconnects.patch +cifs-fix-reconnect-on-smb3-mount-types.patch +cifs-populate-empty-hostnames-for-extra-channels.patch