Merge tag 'v6.16-rc2-smb3-client-fixes-v2' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

- Multichannel channel allocation fix for Kerberos mounts

- Two reconnect fixes

- Fix netfs_writepages crash with smbdirect/RDMA

- Directory caching fix

- Three minor cleanup fixes

- Log error when close cached dirs fails

* tag 'v6.16-rc2-smb3-client-fixes-v2' of git://git.samba.org/sfrench/cifs-2.6:
smb: minor fix to use SMB2_NTLMV2_SESSKEY_SIZE for auth_key size
smb: minor fix to use sizeof to initialize flags_string buffer
smb: Use loff_t for directory position in cached_dirents
smb: Log an error when close_all_cached_dirs fails
cifs: Fix prepare_write to negotiate wsize if needed
smb: client: fix max_sge overflow in smb_extract_folioq_to_rdma()
smb: client: fix first command failure during re-negotiation
cifs: Remove duplicate fattr->cf_dtype assignment from wsl_to_fattr() function
smb: fix secondary channel creation issue with kerberos by populating hostname when adding channels

+27 -13
+12 -2
fs/smb/client/cached_dir.c
··· 509 spin_lock(&cfids->cfid_list_lock); 510 list_for_each_entry(cfid, &cfids->entries, entry) { 511 tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC); 512 - if (tmp_list == NULL) 513 - break; 514 spin_lock(&cfid->fid_lock); 515 tmp_list->dentry = cfid->dentry; 516 cfid->dentry = NULL; ··· 531 } 532 spin_unlock(&cifs_sb->tlink_tree_lock); 533 534 list_for_each_entry_safe(tmp_list, q, &entry, entry) { 535 list_del(&tmp_list->entry); 536 dput(tmp_list->dentry);
··· 509 spin_lock(&cfids->cfid_list_lock); 510 list_for_each_entry(cfid, &cfids->entries, entry) { 511 tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC); 512 + if (tmp_list == NULL) { 513 + /* 514 + * If the malloc() fails, we won't drop all 515 + * dentries, and unmounting is likely to trigger 516 + * a 'Dentry still in use' error. 517 + */ 518 + cifs_tcon_dbg(VFS, "Out of memory while dropping dentries\n"); 519 + spin_unlock(&cfids->cfid_list_lock); 520 + spin_unlock(&cifs_sb->tlink_tree_lock); 521 + goto done; 522 + } 523 spin_lock(&cfid->fid_lock); 524 tmp_list->dentry = cfid->dentry; 525 cfid->dentry = NULL; ··· 522 } 523 spin_unlock(&cifs_sb->tlink_tree_lock); 524 525 + done: 526 list_for_each_entry_safe(tmp_list, q, &entry, entry) { 527 list_del(&tmp_list->entry); 528 dput(tmp_list->dentry);
+1 -1
fs/smb/client/cached_dir.h
··· 26 * open file instance. 27 */ 28 struct mutex de_mutex; 29 - int pos; /* Expected ctx->pos */ 30 struct list_head entries; 31 }; 32
··· 26 * open file instance. 27 */ 28 struct mutex de_mutex; 29 + loff_t pos; /* Expected ctx->pos */ 30 struct list_head entries; 31 }; 32
+1 -1
fs/smb/client/cifs_debug.c
··· 1105 if ((count < 1) || (count > 11)) 1106 return -EINVAL; 1107 1108 - memset(flags_string, 0, 12); 1109 1110 if (copy_from_user(flags_string, buffer, count)) 1111 return -EFAULT;
··· 1105 if ((count < 1) || (count > 11)) 1106 return -EINVAL; 1107 1108 + memset(flags_string, 0, sizeof(flags_string)); 1109 1110 if (copy_from_user(flags_string, buffer, count)) 1111 return -EFAULT;
+1 -1
fs/smb/client/cifs_ioctl.h
··· 61 struct smb3_key_debug_info { 62 __u64 Suid; 63 __u16 cipher_type; 64 - __u8 auth_key[16]; /* SMB2_NTLMV2_SESSKEY_SIZE */ 65 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; 66 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 67 } __packed;
··· 61 struct smb3_key_debug_info { 62 __u64 Suid; 63 __u16 cipher_type; 64 + __u8 auth_key[SMB2_NTLMV2_SESSKEY_SIZE]; 65 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; 66 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 67 } __packed;
+1
fs/smb/client/connect.c
··· 4199 return 0; 4200 } 4201 4202 server->tcpStatus = CifsInNegotiate; 4203 spin_unlock(&server->srv_lock); 4204
··· 4199 return 0; 4200 } 4201 4202 + server->lstrp = jiffies; 4203 server->tcpStatus = CifsInNegotiate; 4204 spin_unlock(&server->srv_lock); 4205
+6 -2
fs/smb/client/file.c
··· 52 struct netfs_io_stream *stream = &req->rreq.io_streams[subreq->stream_nr]; 53 struct TCP_Server_Info *server; 54 struct cifsFileInfo *open_file = req->cfile; 55 size_t wsize = req->rreq.wsize; 56 int rc; 57 ··· 63 64 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); 65 wdata->server = server; 66 67 retry: 68 if (open_file->invalidHandle) { ··· 165 server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses); 166 rdata->server = server; 167 168 - if (cifs_sb->ctx->rsize == 0) { 169 cifs_negotiate_rsize(server, cifs_sb->ctx, 170 tlink_tcon(req->cfile->tlink)); 171 - } 172 173 rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize, 174 &size, &rdata->credits);
··· 52 struct netfs_io_stream *stream = &req->rreq.io_streams[subreq->stream_nr]; 53 struct TCP_Server_Info *server; 54 struct cifsFileInfo *open_file = req->cfile; 55 + struct cifs_sb_info *cifs_sb = CIFS_SB(wdata->rreq->inode->i_sb); 56 size_t wsize = req->rreq.wsize; 57 int rc; 58 ··· 62 63 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); 64 wdata->server = server; 65 + 66 + if (cifs_sb->ctx->wsize == 0) 67 + cifs_negotiate_wsize(server, cifs_sb->ctx, 68 + tlink_tcon(req->cfile->tlink)); 69 70 retry: 71 if (open_file->invalidHandle) { ··· 160 server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses); 161 rdata->server = server; 162 163 + if (cifs_sb->ctx->rsize == 0) 164 cifs_negotiate_rsize(server, cifs_sb->ctx, 165 tlink_tcon(req->cfile->tlink)); 166 167 rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize, 168 &size, &rdata->credits);
+1 -1
fs/smb/client/ioctl.c
··· 506 le16_to_cpu(tcon->ses->server->cipher_type); 507 pkey_inf.Suid = tcon->ses->Suid; 508 memcpy(pkey_inf.auth_key, tcon->ses->auth_key.response, 509 - 16 /* SMB2_NTLMV2_SESSKEY_SIZE */); 510 memcpy(pkey_inf.smb3decryptionkey, 511 tcon->ses->smb3decryptionkey, SMB3_SIGN_KEY_SIZE); 512 memcpy(pkey_inf.smb3encryptionkey,
··· 506 le16_to_cpu(tcon->ses->server->cipher_type); 507 pkey_inf.Suid = tcon->ses->Suid; 508 memcpy(pkey_inf.auth_key, tcon->ses->auth_key.response, 509 + SMB2_NTLMV2_SESSKEY_SIZE); 510 memcpy(pkey_inf.smb3decryptionkey, 511 tcon->ses->smb3decryptionkey, SMB3_SIGN_KEY_SIZE); 512 memcpy(pkey_inf.smb3encryptionkey,
-1
fs/smb/client/reparse.c
··· 1172 if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK)) 1173 return false; 1174 1175 - fattr->cf_dtype = S_DT(fattr->cf_mode); 1176 return true; 1177 } 1178
··· 1172 if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK)) 1173 return false; 1174 1175 return true; 1176 } 1177
+1 -2
fs/smb/client/sess.c
··· 498 ctx->domainauto = ses->domainAuto; 499 ctx->domainname = ses->domainName; 500 501 - /* no hostname for extra channels */ 502 - ctx->server_hostname = ""; 503 504 ctx->username = ses->user_name; 505 ctx->password = ses->password;
··· 498 ctx->domainauto = ses->domainAuto; 499 ctx->domainname = ses->domainName; 500 501 + ctx->server_hostname = ses->server->hostname; 502 503 ctx->username = ses->user_name; 504 ctx->password = ses->password;
+3 -2
fs/smb/client/smbdirect.c
··· 2589 size_t fsize = folioq_folio_size(folioq, slot); 2590 2591 if (offset < fsize) { 2592 - size_t part = umin(maxsize - ret, fsize - offset); 2593 2594 if (!smb_set_sge(rdma, folio_page(folio, 0), offset, part)) 2595 return -EIO; 2596 2597 offset += part; 2598 ret += part; 2599 } 2600 2601 if (offset >= fsize) { ··· 2611 slot = 0; 2612 } 2613 } 2614 - } while (rdma->nr_sge < rdma->max_sge || maxsize > 0); 2615 2616 iter->folioq = folioq; 2617 iter->folioq_slot = slot;
··· 2589 size_t fsize = folioq_folio_size(folioq, slot); 2590 2591 if (offset < fsize) { 2592 + size_t part = umin(maxsize, fsize - offset); 2593 2594 if (!smb_set_sge(rdma, folio_page(folio, 0), offset, part)) 2595 return -EIO; 2596 2597 offset += part; 2598 ret += part; 2599 + maxsize -= part; 2600 } 2601 2602 if (offset >= fsize) { ··· 2610 slot = 0; 2611 } 2612 } 2613 + } while (rdma->nr_sge < rdma->max_sge && maxsize > 0); 2614 2615 iter->folioq = folioq; 2616 iter->folioq_slot = slot;