Skip to content

Commit 75f99f8

Browse files
committed
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
2 parents 739a6c9 + 27e9d5d commit 75f99f8

File tree

10 files changed

+27
-13
lines changed

10 files changed

+27
-13
lines changed

fs/smb/client/cached_dir.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,17 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
509509
spin_lock(&cfids->cfid_list_lock);
510510
list_for_each_entry(cfid, &cfids->entries, entry) {
511511
tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC);
512-
if (tmp_list == NULL)
513-
break;
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+
}
514523
spin_lock(&cfid->fid_lock);
515524
tmp_list->dentry = cfid->dentry;
516525
cfid->dentry = NULL;
@@ -522,6 +531,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
522531
}
523532
spin_unlock(&cifs_sb->tlink_tree_lock);
524533

534+
done:
525535
list_for_each_entry_safe(tmp_list, q, &entry, entry) {
526536
list_del(&tmp_list->entry);
527537
dput(tmp_list->dentry);

fs/smb/client/cached_dir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct cached_dirents {
2626
* open file instance.
2727
*/
2828
struct mutex de_mutex;
29-
int pos; /* Expected ctx->pos */
29+
loff_t pos; /* Expected ctx->pos */
3030
struct list_head entries;
3131
};
3232

fs/smb/client/cifs_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
11051105
if ((count < 1) || (count > 11))
11061106
return -EINVAL;
11071107

1108-
memset(flags_string, 0, 12);
1108+
memset(flags_string, 0, sizeof(flags_string));
11091109

11101110
if (copy_from_user(flags_string, buffer, count))
11111111
return -EFAULT;

fs/smb/client/cifs_ioctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct smb_query_info {
6161
struct smb3_key_debug_info {
6262
__u64 Suid;
6363
__u16 cipher_type;
64-
__u8 auth_key[16]; /* SMB2_NTLMV2_SESSKEY_SIZE */
64+
__u8 auth_key[SMB2_NTLMV2_SESSKEY_SIZE];
6565
__u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
6666
__u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
6767
} __packed;

fs/smb/client/connect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,6 +4199,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
41994199
return 0;
42004200
}
42014201

4202+
server->lstrp = jiffies;
42024203
server->tcpStatus = CifsInNegotiate;
42034204
spin_unlock(&server->srv_lock);
42044205

fs/smb/client/file.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
5252
struct netfs_io_stream *stream = &req->rreq.io_streams[subreq->stream_nr];
5353
struct TCP_Server_Info *server;
5454
struct cifsFileInfo *open_file = req->cfile;
55+
struct cifs_sb_info *cifs_sb = CIFS_SB(wdata->rreq->inode->i_sb);
5556
size_t wsize = req->rreq.wsize;
5657
int rc;
5758

@@ -63,6 +64,10 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
6364
server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses);
6465
wdata->server = server;
6566

67+
if (cifs_sb->ctx->wsize == 0)
68+
cifs_negotiate_wsize(server, cifs_sb->ctx,
69+
tlink_tcon(req->cfile->tlink));
70+
6671
retry:
6772
if (open_file->invalidHandle) {
6873
rc = cifs_reopen_file(open_file, false);
@@ -160,10 +165,9 @@ static int cifs_prepare_read(struct netfs_io_subrequest *subreq)
160165
server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses);
161166
rdata->server = server;
162167

163-
if (cifs_sb->ctx->rsize == 0) {
168+
if (cifs_sb->ctx->rsize == 0)
164169
cifs_negotiate_rsize(server, cifs_sb->ctx,
165170
tlink_tcon(req->cfile->tlink));
166-
}
167171

168172
rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
169173
&size, &rdata->credits);

fs/smb/client/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
506506
le16_to_cpu(tcon->ses->server->cipher_type);
507507
pkey_inf.Suid = tcon->ses->Suid;
508508
memcpy(pkey_inf.auth_key, tcon->ses->auth_key.response,
509-
16 /* SMB2_NTLMV2_SESSKEY_SIZE */);
509+
SMB2_NTLMV2_SESSKEY_SIZE);
510510
memcpy(pkey_inf.smb3decryptionkey,
511511
tcon->ses->smb3decryptionkey, SMB3_SIGN_KEY_SIZE);
512512
memcpy(pkey_inf.smb3encryptionkey,

fs/smb/client/reparse.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,6 @@ static bool wsl_to_fattr(struct cifs_open_info_data *data,
11721172
if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK))
11731173
return false;
11741174

1175-
fattr->cf_dtype = S_DT(fattr->cf_mode);
11761175
return true;
11771176
}
11781177

fs/smb/client/sess.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ cifs_ses_add_channel(struct cifs_ses *ses,
498498
ctx->domainauto = ses->domainAuto;
499499
ctx->domainname = ses->domainName;
500500

501-
/* no hostname for extra channels */
502-
ctx->server_hostname = "";
501+
ctx->server_hostname = ses->server->hostname;
503502

504503
ctx->username = ses->user_name;
505504
ctx->password = ses->password;

fs/smb/client/smbdirect.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,13 +2589,14 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter,
25892589
size_t fsize = folioq_folio_size(folioq, slot);
25902590

25912591
if (offset < fsize) {
2592-
size_t part = umin(maxsize - ret, fsize - offset);
2592+
size_t part = umin(maxsize, fsize - offset);
25932593

25942594
if (!smb_set_sge(rdma, folio_page(folio, 0), offset, part))
25952595
return -EIO;
25962596

25972597
offset += part;
25982598
ret += part;
2599+
maxsize -= part;
25992600
}
26002601

26012602
if (offset >= fsize) {
@@ -2610,7 +2611,7 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter,
26102611
slot = 0;
26112612
}
26122613
}
2613-
} while (rdma->nr_sge < rdma->max_sge || maxsize > 0);
2614+
} while (rdma->nr_sge < rdma->max_sge && maxsize > 0);
26142615

26152616
iter->folioq = folioq;
26162617
iter->folioq_slot = slot;

0 commit comments

Comments
 (0)