nine smb3 client fixes

-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE6fsu8pdIjtWE/DpLiiy9cAdyT1EFAmhW2HgACgkQiiy9cAdy
 T1GOKQwAtXGEBIPsMMIDUISCFRVMFShbDdROFZHEUqGLM3Ere/tzahj1hF+zFC+I
 um0h6swEyYod72Ay4Ltkfupk6++6loonSQibZiXZMJRQzJywhPd/d+W6TyE512bf
 uyCYd0/DvC7hvkDXlxSrukDdJ/qbBggdoIMYI/SU9sZepURc+nl5Dud9sT3dXXxr
 1+tr6hRorOUr6Tot7oPnJNHIUvFmRSo+aYLQbHzheYLwBYn3b7yq8Ep9txDr6z+v
 WYaxMsy9ukxCgaaPKsZmGBrD0D4wE+MzOgPA+f5zZhxOGpYQF+GLbovabyynqPff
 XyUY2NPMECQTyZaCpiq0ydORCkusgqyCEK+GazHjebuKosutHOzUyOvsZBvKS1ww
 dQW4Ukjn3ge1eXeRuS1BwvBRD2okB2ODyelG4QDzw93Jbh/jwuhCxyw0Cc76Umps
 mOaeCujd93X/hpBwA+KYPxlpzUnf1TzhOkP2RUWyKKuibE8WDcUyJVEnMa3mC3NR
 aPmK/F07
 =vZhQ
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2025-06-22 09:46:11 -07:00
commit 75f99f8cf4
10 changed files with 27 additions and 13 deletions

View file

@ -509,8 +509,17 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry(cfid, &cfids->entries, entry) {
tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC);
if (tmp_list == NULL)
break;
if (tmp_list == NULL) {
/*
* If the malloc() fails, we won't drop all
* dentries, and unmounting is likely to trigger
* a 'Dentry still in use' error.
*/
cifs_tcon_dbg(VFS, "Out of memory while dropping dentries\n");
spin_unlock(&cfids->cfid_list_lock);
spin_unlock(&cifs_sb->tlink_tree_lock);
goto done;
}
spin_lock(&cfid->fid_lock);
tmp_list->dentry = cfid->dentry;
cfid->dentry = NULL;
@ -522,6 +531,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
}
spin_unlock(&cifs_sb->tlink_tree_lock);
done:
list_for_each_entry_safe(tmp_list, q, &entry, entry) {
list_del(&tmp_list->entry);
dput(tmp_list->dentry);

View file

@ -26,7 +26,7 @@ struct cached_dirents {
* open file instance.
*/
struct mutex de_mutex;
int pos; /* Expected ctx->pos */
loff_t pos; /* Expected ctx->pos */
struct list_head entries;
};

View file

@ -1105,7 +1105,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
if ((count < 1) || (count > 11))
return -EINVAL;
memset(flags_string, 0, 12);
memset(flags_string, 0, sizeof(flags_string));
if (copy_from_user(flags_string, buffer, count))
return -EFAULT;

View file

@ -61,7 +61,7 @@ struct smb_query_info {
struct smb3_key_debug_info {
__u64 Suid;
__u16 cipher_type;
__u8 auth_key[16]; /* SMB2_NTLMV2_SESSKEY_SIZE */
__u8 auth_key[SMB2_NTLMV2_SESSKEY_SIZE];
__u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
__u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
} __packed;

View file

@ -4199,6 +4199,7 @@ retry:
return 0;
}
server->lstrp = jiffies;
server->tcpStatus = CifsInNegotiate;
spin_unlock(&server->srv_lock);

View file

@ -52,6 +52,7 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
struct netfs_io_stream *stream = &req->rreq.io_streams[subreq->stream_nr];
struct TCP_Server_Info *server;
struct cifsFileInfo *open_file = req->cfile;
struct cifs_sb_info *cifs_sb = CIFS_SB(wdata->rreq->inode->i_sb);
size_t wsize = req->rreq.wsize;
int rc;
@ -63,6 +64,10 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses);
wdata->server = server;
if (cifs_sb->ctx->wsize == 0)
cifs_negotiate_wsize(server, cifs_sb->ctx,
tlink_tcon(req->cfile->tlink));
retry:
if (open_file->invalidHandle) {
rc = cifs_reopen_file(open_file, false);
@ -160,10 +165,9 @@ static int cifs_prepare_read(struct netfs_io_subrequest *subreq)
server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses);
rdata->server = server;
if (cifs_sb->ctx->rsize == 0) {
if (cifs_sb->ctx->rsize == 0)
cifs_negotiate_rsize(server, cifs_sb->ctx,
tlink_tcon(req->cfile->tlink));
}
rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
&size, &rdata->credits);

View file

@ -506,7 +506,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
le16_to_cpu(tcon->ses->server->cipher_type);
pkey_inf.Suid = tcon->ses->Suid;
memcpy(pkey_inf.auth_key, tcon->ses->auth_key.response,
16 /* SMB2_NTLMV2_SESSKEY_SIZE */);
SMB2_NTLMV2_SESSKEY_SIZE);
memcpy(pkey_inf.smb3decryptionkey,
tcon->ses->smb3decryptionkey, SMB3_SIGN_KEY_SIZE);
memcpy(pkey_inf.smb3encryptionkey,

View file

@ -1172,7 +1172,6 @@ out:
if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK))
return false;
fattr->cf_dtype = S_DT(fattr->cf_mode);
return true;
}

View file

@ -498,8 +498,7 @@ cifs_ses_add_channel(struct cifs_ses *ses,
ctx->domainauto = ses->domainAuto;
ctx->domainname = ses->domainName;
/* no hostname for extra channels */
ctx->server_hostname = "";
ctx->server_hostname = ses->server->hostname;
ctx->username = ses->user_name;
ctx->password = ses->password;

View file

@ -2589,13 +2589,14 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter,
size_t fsize = folioq_folio_size(folioq, slot);
if (offset < fsize) {
size_t part = umin(maxsize - ret, fsize - offset);
size_t part = umin(maxsize, fsize - offset);
if (!smb_set_sge(rdma, folio_page(folio, 0), offset, part))
return -EIO;
offset += part;
ret += part;
maxsize -= part;
}
if (offset >= fsize) {
@ -2610,7 +2611,7 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter,
slot = 0;
}
}
} while (rdma->nr_sge < rdma->max_sge || maxsize > 0);
} while (rdma->nr_sge < rdma->max_sge && maxsize > 0);
iter->folioq = folioq;
iter->folioq_slot = slot;