]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.17-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 08:39:44 +0000 (10:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 08:39:44 +0000 (10:39 +0200)
added patches:
cifs-don-t-call-cifs_dfs_query_info_nonascii_quirk-if-nodfs-was-set.patch
cifs-fix-ntlmssp-on-old-servers.patch
cifs-fix-potential-double-free-during-failed-mount.patch
cifs-when-extending-a-file-with-falloc-we-should-make-files-not-sparse.patch
xhci-allow-host-runtime-pm-as-default-for-intel-alder-lake-n-xhci.patch

queue-5.17/cifs-don-t-call-cifs_dfs_query_info_nonascii_quirk-if-nodfs-was-set.patch [new file with mode: 0644]
queue-5.17/cifs-fix-ntlmssp-on-old-servers.patch [new file with mode: 0644]
queue-5.17/cifs-fix-potential-double-free-during-failed-mount.patch [new file with mode: 0644]
queue-5.17/cifs-when-extending-a-file-with-falloc-we-should-make-files-not-sparse.patch [new file with mode: 0644]
queue-5.17/series
queue-5.17/xhci-allow-host-runtime-pm-as-default-for-intel-alder-lake-n-xhci.patch [new file with mode: 0644]

diff --git a/queue-5.17/cifs-don-t-call-cifs_dfs_query_info_nonascii_quirk-if-nodfs-was-set.patch b/queue-5.17/cifs-don-t-call-cifs_dfs_query_info_nonascii_quirk-if-nodfs-was-set.patch
new file mode 100644 (file)
index 0000000..9b152ca
--- /dev/null
@@ -0,0 +1,64 @@
+From 421ef3d56513b2ff02e563623688cb6ab4977c4f Mon Sep 17 00:00:00 2001
+From: Enzo Matsumiya <ematsumiya@suse.de>
+Date: Wed, 18 May 2022 13:31:55 -0300
+Subject: cifs: don't call cifs_dfs_query_info_nonascii_quirk() if nodfs was set
+
+From: Enzo Matsumiya <ematsumiya@suse.de>
+
+commit 421ef3d56513b2ff02e563623688cb6ab4977c4f upstream.
+
+Also return EOPNOTSUPP if path is remote but nodfs was set.
+
+Fixes: a2809d0e1696 ("cifs: quirk for STATUS_OBJECT_NAME_INVALID returned for non-ASCII dfs refs")
+Cc: stable@vger.kernel.org
+Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
+Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/connect.c |   16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
+
+--- a/fs/cifs/connect.c
++++ b/fs/cifs/connect.c
+@@ -3432,6 +3432,7 @@ static int is_path_remote(struct mount_c
+       struct cifs_tcon *tcon = mnt_ctx->tcon;
+       struct smb3_fs_context *ctx = mnt_ctx->fs_ctx;
+       char *full_path;
++      bool nodfs = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS;
+       if (!server->ops->is_path_accessible)
+               return -EOPNOTSUPP;
+@@ -3449,14 +3450,20 @@ static int is_path_remote(struct mount_c
+       rc = server->ops->is_path_accessible(xid, tcon, cifs_sb,
+                                            full_path);
+ #ifdef CONFIG_CIFS_DFS_UPCALL
++      if (nodfs) {
++              if (rc == -EREMOTE)
++                      rc = -EOPNOTSUPP;
++              goto out;
++      }
++
++      /* path *might* exist with non-ASCII characters in DFS root
++       * try again with full path (only if nodfs is not set) */
+       if (rc == -ENOENT && is_tcon_dfs(tcon))
+               rc = cifs_dfs_query_info_nonascii_quirk(xid, tcon, cifs_sb,
+                                                       full_path);
+ #endif
+-      if (rc != 0 && rc != -EREMOTE) {
+-              kfree(full_path);
+-              return rc;
+-      }
++      if (rc != 0 && rc != -EREMOTE)
++              goto out;
+       if (rc != -EREMOTE) {
+               rc = cifs_are_all_path_components_accessible(server, xid, tcon,
+@@ -3468,6 +3475,7 @@ static int is_path_remote(struct mount_c
+               }
+       }
++out:
+       kfree(full_path);
+       return rc;
+ }
diff --git a/queue-5.17/cifs-fix-ntlmssp-on-old-servers.patch b/queue-5.17/cifs-fix-ntlmssp-on-old-servers.patch
new file mode 100644 (file)
index 0000000..ad4b0b9
--- /dev/null
@@ -0,0 +1,227 @@
+From de3a9e943ddecba8d2ac1dde4cfff538e5c6a7b9 Mon Sep 17 00:00:00 2001
+From: Paulo Alcantara <pc@cjr.nz>
+Date: Wed, 25 May 2022 07:37:04 -0500
+Subject: cifs: fix ntlmssp on old servers
+
+From: Paulo Alcantara <pc@cjr.nz>
+
+commit de3a9e943ddecba8d2ac1dde4cfff538e5c6a7b9 upstream.
+
+Some older servers seem to require the workstation name during ntlmssp
+to be at most 15 chars (RFC1001 name length), so truncate it before
+sending when using insecure dialects.
+
+Link: https://lore.kernel.org/r/e6837098-15d9-acb6-7e34-1923cf8c6fe1@winds.org
+Reported-by: Byron Stanoszek <gandalf@winds.org>
+Tested-by: Byron Stanoszek <gandalf@winds.org>
+Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup")
+Cc: stable@vger.kernel.org
+Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/cifsglob.h   |   15 ++++++++++++++-
+ fs/cifs/connect.c    |   22 ++++------------------
+ fs/cifs/fs_context.c |   29 ++++-------------------------
+ fs/cifs/fs_context.h |    2 +-
+ fs/cifs/misc.c       |    1 -
+ fs/cifs/sess.c       |    6 +++---
+ 6 files changed, 26 insertions(+), 49 deletions(-)
+
+--- a/fs/cifs/cifsglob.h
++++ b/fs/cifs/cifsglob.h
+@@ -949,7 +949,7 @@ struct cifs_ses {
+                                  and after mount option parsing we fill it */
+       char *domainName;
+       char *password;
+-      char *workstation_name;
++      char workstation_name[CIFS_MAX_WORKSTATION_LEN];
+       struct session_key auth_key;
+       struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
+       enum securityEnum sectype; /* what security flavor was specified? */
+@@ -1983,4 +1983,17 @@ static inline bool cifs_is_referral_serv
+       return is_tcon_dfs(tcon) || (ref && (ref->flags & DFSREF_REFERRAL_SERVER));
+ }
++static inline size_t ntlmssp_workstation_name_size(const struct cifs_ses *ses)
++{
++      if (WARN_ON_ONCE(!ses || !ses->server))
++              return 0;
++      /*
++       * Make workstation name no more than 15 chars when using insecure dialects as some legacy
++       * servers do require it during NTLMSSP.
++       */
++      if (ses->server->dialect <= SMB20_PROT_ID)
++              return min_t(size_t, sizeof(ses->workstation_name), RFC1001_NAME_LEN_WITH_NULL);
++      return sizeof(ses->workstation_name);
++}
++
+ #endif        /* _CIFS_GLOB_H */
+--- a/fs/cifs/connect.c
++++ b/fs/cifs/connect.c
+@@ -2037,18 +2037,7 @@ cifs_set_cifscreds(struct smb3_fs_contex
+               }
+       }
+-      ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL);
+-      if (!ctx->workstation_name) {
+-              cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n");
+-              rc = -ENOMEM;
+-              kfree(ctx->username);
+-              ctx->username = NULL;
+-              kfree_sensitive(ctx->password);
+-              ctx->password = NULL;
+-              kfree(ctx->domainname);
+-              ctx->domainname = NULL;
+-              goto out_key_put;
+-      }
++      strscpy(ctx->workstation_name, ses->workstation_name, sizeof(ctx->workstation_name));
+ out_key_put:
+       up_read(&key->sem);
+@@ -2157,12 +2146,9 @@ cifs_get_smb_ses(struct TCP_Server_Info
+               if (!ses->domainName)
+                       goto get_ses_fail;
+       }
+-      if (ctx->workstation_name) {
+-              ses->workstation_name = kstrdup(ctx->workstation_name,
+-                                              GFP_KERNEL);
+-              if (!ses->workstation_name)
+-                      goto get_ses_fail;
+-      }
++
++      strscpy(ses->workstation_name, ctx->workstation_name, sizeof(ses->workstation_name));
++
+       if (ctx->domainauto)
+               ses->domainAuto = ctx->domainauto;
+       ses->cred_uid = ctx->cred_uid;
+--- a/fs/cifs/fs_context.c
++++ b/fs/cifs/fs_context.c
+@@ -312,7 +312,6 @@ smb3_fs_context_dup(struct smb3_fs_conte
+       new_ctx->password = NULL;
+       new_ctx->server_hostname = NULL;
+       new_ctx->domainname = NULL;
+-      new_ctx->workstation_name = NULL;
+       new_ctx->UNC = NULL;
+       new_ctx->source = NULL;
+       new_ctx->iocharset = NULL;
+@@ -327,7 +326,6 @@ smb3_fs_context_dup(struct smb3_fs_conte
+       DUP_CTX_STR(UNC);
+       DUP_CTX_STR(source);
+       DUP_CTX_STR(domainname);
+-      DUP_CTX_STR(workstation_name);
+       DUP_CTX_STR(nodename);
+       DUP_CTX_STR(iocharset);
+@@ -766,8 +764,7 @@ static int smb3_verify_reconfigure_ctx(s
+               cifs_errorf(fc, "can not change domainname during remount\n");
+               return -EINVAL;
+       }
+-      if (new_ctx->workstation_name &&
+-          (!old_ctx->workstation_name || strcmp(new_ctx->workstation_name, old_ctx->workstation_name))) {
++      if (strcmp(new_ctx->workstation_name, old_ctx->workstation_name)) {
+               cifs_errorf(fc, "can not change workstation_name during remount\n");
+               return -EINVAL;
+       }
+@@ -814,7 +811,6 @@ static int smb3_reconfigure(struct fs_co
+       STEAL_STRING(cifs_sb, ctx, username);
+       STEAL_STRING(cifs_sb, ctx, password);
+       STEAL_STRING(cifs_sb, ctx, domainname);
+-      STEAL_STRING(cifs_sb, ctx, workstation_name);
+       STEAL_STRING(cifs_sb, ctx, nodename);
+       STEAL_STRING(cifs_sb, ctx, iocharset);
+@@ -1467,22 +1463,15 @@ static int smb3_fs_context_parse_param(s
+ int smb3_init_fs_context(struct fs_context *fc)
+ {
+-      int rc;
+       struct smb3_fs_context *ctx;
+       char *nodename = utsname()->nodename;
+       int i;
+       ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
+-      if (unlikely(!ctx)) {
+-              rc = -ENOMEM;
+-              goto err_exit;
+-      }
++      if (unlikely(!ctx))
++              return -ENOMEM;
+-      ctx->workstation_name = kstrdup(nodename, GFP_KERNEL);
+-      if (unlikely(!ctx->workstation_name)) {
+-              rc = -ENOMEM;
+-              goto err_exit;
+-      }
++      strscpy(ctx->workstation_name, nodename, sizeof(ctx->workstation_name));
+       /*
+        * does not have to be perfect mapping since field is
+@@ -1555,14 +1544,6 @@ int smb3_init_fs_context(struct fs_conte
+       fc->fs_private = ctx;
+       fc->ops = &smb3_fs_context_ops;
+       return 0;
+-
+-err_exit:
+-      if (ctx) {
+-              kfree(ctx->workstation_name);
+-              kfree(ctx);
+-      }
+-
+-      return rc;
+ }
+ void
+@@ -1588,8 +1569,6 @@ smb3_cleanup_fs_context_contents(struct
+       ctx->source = NULL;
+       kfree(ctx->domainname);
+       ctx->domainname = NULL;
+-      kfree(ctx->workstation_name);
+-      ctx->workstation_name = NULL;
+       kfree(ctx->nodename);
+       ctx->nodename = NULL;
+       kfree(ctx->iocharset);
+--- a/fs/cifs/fs_context.h
++++ b/fs/cifs/fs_context.h
+@@ -170,7 +170,7 @@ struct smb3_fs_context {
+       char *server_hostname;
+       char *UNC;
+       char *nodename;
+-      char *workstation_name;
++      char workstation_name[CIFS_MAX_WORKSTATION_LEN];
+       char *iocharset;  /* local code page for mapping to and from Unicode */
+       char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
+       char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
+--- a/fs/cifs/misc.c
++++ b/fs/cifs/misc.c
+@@ -95,7 +95,6 @@ sesInfoFree(struct cifs_ses *buf_to_free
+       kfree_sensitive(buf_to_free->password);
+       kfree(buf_to_free->user_name);
+       kfree(buf_to_free->domainName);
+-      kfree(buf_to_free->workstation_name);
+       kfree_sensitive(buf_to_free->auth_key.response);
+       kfree(buf_to_free->iface_list);
+       kfree_sensitive(buf_to_free);
+--- a/fs/cifs/sess.c
++++ b/fs/cifs/sess.c
+@@ -714,9 +714,9 @@ static int size_of_ntlmssp_blob(struct c
+       else
+               sz += sizeof(__le16);
+-      if (ses->workstation_name)
++      if (ses->workstation_name[0])
+               sz += sizeof(__le16) * strnlen(ses->workstation_name,
+-                      CIFS_MAX_WORKSTATION_LEN);
++                                             ntlmssp_workstation_name_size(ses));
+       else
+               sz += sizeof(__le16);
+@@ -960,7 +960,7 @@ int build_ntlmssp_auth_blob(unsigned cha
+       cifs_security_buffer_from_str(&sec_blob->WorkstationName,
+                                     ses->workstation_name,
+-                                    CIFS_MAX_WORKSTATION_LEN,
++                                    ntlmssp_workstation_name_size(ses),
+                                     *pbuffer, &tmp,
+                                     nls_cp);
diff --git a/queue-5.17/cifs-fix-potential-double-free-during-failed-mount.patch b/queue-5.17/cifs-fix-potential-double-free-during-failed-mount.patch
new file mode 100644 (file)
index 0000000..8f4e92e
--- /dev/null
@@ -0,0 +1,46 @@
+From 8378a51e3f8140f60901fb27208cc7a6e47047b5 Mon Sep 17 00:00:00 2001
+From: Ronnie Sahlberg <lsahlber@redhat.com>
+Date: Tue, 31 May 2022 13:01:17 +1000
+Subject: cifs: fix potential double free during failed mount
+
+From: Ronnie Sahlberg <lsahlber@redhat.com>
+
+commit 8378a51e3f8140f60901fb27208cc7a6e47047b5 upstream.
+
+RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2088799
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Roberto Bergantinos <rbergant@redhat.com>
+Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/cifsfs.c |   10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+--- a/fs/cifs/cifsfs.c
++++ b/fs/cifs/cifsfs.c
+@@ -836,7 +836,7 @@ cifs_smb3_do_mount(struct file_system_ty
+             int flags, struct smb3_fs_context *old_ctx)
+ {
+       int rc;
+-      struct super_block *sb;
++      struct super_block *sb = NULL;
+       struct cifs_sb_info *cifs_sb = NULL;
+       struct cifs_mnt_data mnt_data;
+       struct dentry *root;
+@@ -932,9 +932,11 @@ out_super:
+       return root;
+ out:
+       if (cifs_sb) {
+-              kfree(cifs_sb->prepath);
+-              smb3_cleanup_fs_context(cifs_sb->ctx);
+-              kfree(cifs_sb);
++              if (!sb || IS_ERR(sb)) {  /* otherwise kill_sb will handle */
++                      kfree(cifs_sb->prepath);
++                      smb3_cleanup_fs_context(cifs_sb->ctx);
++                      kfree(cifs_sb);
++              }
+       }
+       return root;
+ }
diff --git a/queue-5.17/cifs-when-extending-a-file-with-falloc-we-should-make-files-not-sparse.patch b/queue-5.17/cifs-when-extending-a-file-with-falloc-we-should-make-files-not-sparse.patch
new file mode 100644 (file)
index 0000000..e0b03a1
--- /dev/null
@@ -0,0 +1,32 @@
+From f66f8b94e7f2f4ac9fffe710be231ca8f25c5057 Mon Sep 17 00:00:00 2001
+From: Ronnie Sahlberg <lsahlber@redhat.com>
+Date: Wed, 1 Jun 2022 08:48:38 +1000
+Subject: cifs: when extending a file with falloc we should make files not-sparse
+
+From: Ronnie Sahlberg <lsahlber@redhat.com>
+
+commit f66f8b94e7f2f4ac9fffe710be231ca8f25c5057 upstream.
+
+as this is the only way to make sure the region is allocated.
+Fix the conditional that was wrong and only tried to make already
+non-sparse files non-sparse.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/cifs/smb2ops.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/cifs/smb2ops.c
++++ b/fs/cifs/smb2ops.c
+@@ -3808,7 +3808,7 @@ static long smb3_simple_falloc(struct fi
+               if (rc)
+                       goto out;
+-              if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)
++              if (cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)
+                       smb2_set_sparse(xid, tcon, cfile, inode, false);
+               eof = cpu_to_le64(off + len);
index bba00a762b84a69411e96bf4d45e13c714e9864d..f1d093017d0767b29eb5c1007d923df296c9a26d 100644 (file)
@@ -25,3 +25,8 @@ fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-f
 fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch
 fs-ntfs3-update-i_ctime-when-xattr-is-added.patch
 fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch
+cifs-don-t-call-cifs_dfs_query_info_nonascii_quirk-if-nodfs-was-set.patch
+cifs-fix-ntlmssp-on-old-servers.patch
+cifs-fix-potential-double-free-during-failed-mount.patch
+cifs-when-extending-a-file-with-falloc-we-should-make-files-not-sparse.patch
+xhci-allow-host-runtime-pm-as-default-for-intel-alder-lake-n-xhci.patch
diff --git a/queue-5.17/xhci-allow-host-runtime-pm-as-default-for-intel-alder-lake-n-xhci.patch b/queue-5.17/xhci-allow-host-runtime-pm-as-default-for-intel-alder-lake-n-xhci.patch
new file mode 100644 (file)
index 0000000..b03ef28
--- /dev/null
@@ -0,0 +1,39 @@
+From 74f55a62c4c354f43a6d75f77dd184c4f57b9a26 Mon Sep 17 00:00:00 2001
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+Date: Thu, 12 May 2022 01:04:50 +0300
+Subject: xhci: Allow host runtime PM as default for Intel Alder Lake N xHCI
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+commit 74f55a62c4c354f43a6d75f77dd184c4f57b9a26 upstream.
+
+Alder Lake N TCSS xHCI needs to be runtime suspended whenever possible
+to allow the TCSS hardware block to enter D3 and thus save energy
+
+Cc: stable@kernel.org
+Suggested-by: Gopal Vamshi Krishna <vamshi.krishna.gopal@intel.com>
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20220511220450.85367-10-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/xhci-pci.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/usb/host/xhci-pci.c
++++ b/drivers/usb/host/xhci-pci.c
+@@ -59,6 +59,7 @@
+ #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI           0x9a13
+ #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI          0x1138
+ #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI           0x461e
++#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI         0x464e
+ #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI       0x51ed
+ #define PCI_DEVICE_ID_AMD_RENOIR_XHCI                 0x1639
+@@ -268,6 +269,7 @@ static void xhci_pci_quirks(struct devic
+            pdev->device == PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI ||
+            pdev->device == PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI ||
+            pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI ||
++           pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI ||
+            pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI))
+               xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;