Skip to content

Commit 3d99347

Browse files
committed
Merge tag 'v6.19-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client updates from Steve French: - multichannel fixes, including enabling ability to change multichannel settings with remount - debugging improvements: adding additional tracepoints, improving log messages - cleanup, including restructuring some of the transport layer for the client to make it clearer, and cleanup of status code table to be more consistent with protocol documentation - fixes for reads that start beyond end of file use cases - fix to backoff reconnects to reduce reconnect storms - locking improvement for getting mid entries - fixes for missing status code error mappings - performance improvement for status code to error mappings * tag 'v6.19-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: (22 commits) smb/client: update some SMB2 status strings cifs: Remove dead function prototypes smb/client: add two elements to smb2_error_map_table array smb: rename to STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP smb/client: remove unused elements from smb2_error_map_table array smb/client: reduce loop count in map_smb2_to_linux_error() by half smb: client: Add tracepoint for krb5 auth smb: client: improve error message when creating SMB session smb: client: relax session and tcon reconnect attempts cifs: Fix handling of a beyond-EOF DIO/unbuffered read over SMB2 cifs: client: allow changing multichannel mount options on remount cifs: Do some preparation prior to organising the function declarations cifs: Add a tracepoint to log EIO errors cifs: Don't need state locking in smb2_get_mid_entry() cifs: Remove the server pointer from smb_message cifs: Fix specification of function pointers cifs: Replace SendReceiveBlockingLock() with SendReceive() plus flags cifs: Clean up some places where an extra kvec[] was required for rfc1002 cifs: Make smb1's SendReceive() wrap cifs_send_recv() cifs: Remove the RFC1002 header from smb_hdr ...
2 parents cb01581 + d8f5265 commit 3d99347

46 files changed

Lines changed: 1740 additions & 1511 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fs/smb/client/cached_dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
176176
server = cifs_pick_channel(ses);
177177

178178
if (!server->ops->new_lease_key)
179-
return -EIO;
179+
return smb_EIO(smb_eio_trace_no_lease_key);
180180

181181
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
182182
if (!utf16_path)

fs/smb/client/cifs_debug.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ cifs_dump_mem(char *label, void *data, int length)
3737
data, length, true);
3838
}
3939

40-
void cifs_dump_detail(void *buf, struct TCP_Server_Info *server)
40+
void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)
4141
{
4242
#ifdef CONFIG_CIFS_DEBUG2
4343
struct smb_hdr *smb = buf;
4444

4545
cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
4646
smb->Command, smb->Status.CifsError, smb->Flags,
4747
smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
48-
if (!server->ops->check_message(buf, server->total_read, server)) {
48+
if (!server->ops->check_message(buf, buf_len, server->total_read, server)) {
4949
cifs_dbg(VFS, "smb buf %p len %u\n", smb,
5050
server->ops->calc_smb_size(smb));
5151
}
@@ -79,9 +79,9 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
7979
cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
8080
mid_entry->multiRsp, mid_entry->multiEnd);
8181
if (mid_entry->resp_buf) {
82-
cifs_dump_detail(mid_entry->resp_buf, server);
83-
cifs_dump_mem("existing buf: ",
84-
mid_entry->resp_buf, 62);
82+
cifs_dump_detail(mid_entry->resp_buf,
83+
mid_entry->response_pdu_len, server);
84+
cifs_dump_mem("existing buf: ", mid_entry->resp_buf, 62);
8585
}
8686
}
8787
spin_unlock(&server->mid_queue_lock);
@@ -1318,11 +1318,11 @@ static const struct proc_ops cifs_mount_params_proc_ops = {
13181318
};
13191319

13201320
#else
1321-
inline void cifs_proc_init(void)
1321+
void cifs_proc_init(void)
13221322
{
13231323
}
13241324

1325-
inline void cifs_proc_clean(void)
1325+
void cifs_proc_clean(void)
13261326
{
13271327
}
13281328
#endif /* PROC_FS */

fs/smb/client/cifs_debug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#define pr_fmt(fmt) "CIFS: " fmt
1616

1717
void cifs_dump_mem(char *label, void *data, int length);
18-
void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
19-
void cifs_dump_mids(struct TCP_Server_Info *);
18+
void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server);
19+
void cifs_dump_mids(struct TCP_Server_Info *server);
2020
extern bool traceSMB; /* flag which enables the function below */
21-
void dump_smb(void *, int);
21+
void dump_smb(void *buf, int smb_buf_length);
2222
#define CIFS_INFO 0x01
2323
#define CIFS_RC 0x02
2424
#define CIFS_TIMER 0x04

fs/smb/client/cifs_spnego.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo,
159159
cifs_dbg(FYI, "key description = %s\n", description);
160160
scoped_with_creds(spnego_cred)
161161
spnego_key = request_key(&cifs_spnego_key_type, description, "");
162+
trace_smb3_kerberos_auth(server, sesInfo, PTR_ERR_OR_ZERO(spnego_key));
162163

163164
#ifdef CONFIG_CIFS_DEBUG2
164165
if (cifsFYI && !IS_ERR(spnego_key)) {

fs/smb/client/cifs_spnego.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ struct cifs_spnego_msg {
2727
uint8_t data[];
2828
};
2929

30-
#ifdef __KERNEL__
3130
extern struct key_type cifs_spnego_key_type;
3231
extern struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo,
3332
struct TCP_Server_Info *server);
34-
#endif /* KERNEL */
3533

3634
#endif /* _CIFS_SPNEGO_H */

fs/smb/client/cifs_unicode.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
#define SFM_MAP_UNI_RSVD 1
5555
#define SFU_MAP_UNI_RSVD 2
5656

57-
#ifdef __KERNEL__
5857
int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
5958
const struct nls_table *cp, int map_type);
6059
int cifs_utf16_bytes(const __le16 *from, int maxbytes,
@@ -69,8 +68,6 @@ extern int cifs_remap(struct cifs_sb_info *cifs_sb);
6968
extern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
7069
int *utf16_len, const struct nls_table *cp,
7170
int remap);
72-
#endif
73-
7471
wchar_t cifs_toupper(wchar_t in);
7572

7673
#endif /* _CIFS_UNICODE_H */

fs/smb/client/cifsacl.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
300300
__func__, sidtype == SIDOWNER ? 'u' : 'g', cid);
301301
goto out_revert_creds;
302302
} else if (sidkey->datalen < CIFS_SID_BASE_SIZE) {
303-
rc = -EIO;
303+
rc = smb_EIO1(smb_eio_trace_malformed_sid_key, sidkey->datalen);
304304
cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
305305
__func__, sidkey->datalen);
306306
goto invalidate_key;
@@ -317,7 +317,8 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
317317

318318
ksid_size = CIFS_SID_BASE_SIZE + (ksid->num_subauth * sizeof(__le32));
319319
if (ksid_size > sidkey->datalen) {
320-
rc = -EIO;
320+
rc = smb_EIO2(smb_eio_trace_malformed_ksid_key,
321+
ksid_size, sidkey->datalen);
321322
cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu, ksid_size=%u)\n",
322323
__func__, sidkey->datalen, ksid_size);
323324
goto invalidate_key;
@@ -352,7 +353,8 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
352353
if (unlikely(psid->num_subauth > SID_MAX_SUB_AUTHORITIES)) {
353354
cifs_dbg(FYI, "%s: %u subauthorities is too many!\n",
354355
__func__, psid->num_subauth);
355-
return -EIO;
356+
return smb_EIO2(smb_eio_trace_sid_too_many_auth,
357+
psid->num_subauth, SID_MAX_SUB_AUTHORITIES);
356358
}
357359

358360
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) ||
@@ -1227,7 +1229,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb,
12271229
__u32 dacloffset;
12281230

12291231
if (pntsd == NULL)
1230-
return -EIO;
1232+
return smb_EIO(smb_eio_trace_null_pointers);
12311233

12321234
owner_sid_ptr = (struct smb_sid *)((char *)pntsd +
12331235
le32_to_cpu(pntsd->osidoffset));

fs/smb/client/cifsencrypt.c

Lines changed: 19 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -75,48 +75,35 @@ static int cifs_sig_iter(const struct iov_iter *iter, size_t maxsize,
7575
struct cifs_calc_sig_ctx *ctx)
7676
{
7777
struct iov_iter tmp_iter = *iter;
78-
int err = -EIO;
78+
size_t did;
79+
int err;
7980

80-
if (iterate_and_advance_kernel(&tmp_iter, maxsize, ctx, &err,
81-
cifs_sig_step) != maxsize)
82-
return err;
81+
did = iterate_and_advance_kernel(&tmp_iter, maxsize, ctx, &err,
82+
cifs_sig_step);
83+
if (did != maxsize)
84+
return smb_EIO2(smb_eio_trace_sig_iter, did, maxsize);
8385
return 0;
8486
}
8587

8688
int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
8789
char *signature, struct cifs_calc_sig_ctx *ctx)
8890
{
89-
int i;
91+
struct iov_iter iter;
9092
ssize_t rc;
91-
struct kvec *iov = rqst->rq_iov;
92-
int n_vec = rqst->rq_nvec;
93-
94-
/* iov[0] is actual data and not the rfc1002 length for SMB2+ */
95-
if (!is_smb1(server)) {
96-
if (iov[0].iov_len <= 4)
97-
return -EIO;
98-
i = 0;
99-
} else {
100-
if (n_vec < 2 || iov[0].iov_len != 4)
101-
return -EIO;
102-
i = 1; /* skip rfc1002 length */
103-
}
93+
size_t size = 0;
10494

105-
for (; i < n_vec; i++) {
106-
if (iov[i].iov_len == 0)
107-
continue;
108-
if (iov[i].iov_base == NULL) {
109-
cifs_dbg(VFS, "null iovec entry\n");
110-
return -EIO;
111-
}
95+
for (int i = 0; i < rqst->rq_nvec; i++)
96+
size += rqst->rq_iov[i].iov_len;
11297

113-
rc = cifs_sig_update(ctx, iov[i].iov_base, iov[i].iov_len);
114-
if (rc) {
115-
cifs_dbg(VFS, "%s: Could not update with payload\n",
116-
__func__);
117-
return rc;
118-
}
119-
}
98+
iov_iter_kvec(&iter, ITER_SOURCE, rqst->rq_iov, rqst->rq_nvec, size);
99+
100+
if (iov_iter_count(&iter) <= 4)
101+
return smb_EIO2(smb_eio_trace_sig_data_too_small,
102+
iov_iter_count(&iter), 4);
103+
104+
rc = cifs_sig_iter(&iter, iov_iter_count(&iter), ctx);
105+
if (rc < 0)
106+
return rc;
120107

121108
rc = cifs_sig_iter(&rqst->rq_iter, iov_iter_count(&rqst->rq_iter), ctx);
122109
if (rc < 0)
@@ -165,10 +152,6 @@ int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
165152
char smb_signature[20];
166153
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
167154

168-
if (rqst->rq_iov[0].iov_len != 4 ||
169-
rqst->rq_iov[0].iov_base + 4 != rqst->rq_iov[1].iov_base)
170-
return -EIO;
171-
172155
if ((cifs_pdu == NULL) || (server == NULL))
173156
return -EINVAL;
174157

@@ -201,30 +184,6 @@ int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
201184
return rc;
202185
}
203186

204-
int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
205-
__u32 *pexpected_response_sequence)
206-
{
207-
struct smb_rqst rqst = { .rq_iov = iov,
208-
.rq_nvec = n_vec };
209-
210-
return cifs_sign_rqst(&rqst, server, pexpected_response_sequence);
211-
}
212-
213-
/* must be called with server->srv_mutex held */
214-
int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
215-
__u32 *pexpected_response_sequence_number)
216-
{
217-
struct kvec iov[2];
218-
219-
iov[0].iov_base = cifs_pdu;
220-
iov[0].iov_len = 4;
221-
iov[1].iov_base = (char *)cifs_pdu + 4;
222-
iov[1].iov_len = be32_to_cpu(cifs_pdu->smb_buf_length);
223-
224-
return cifs_sign_smbv(iov, 2, server,
225-
pexpected_response_sequence_number);
226-
}
227-
228187
int cifs_verify_signature(struct smb_rqst *rqst,
229188
struct TCP_Server_Info *server,
230189
__u32 expected_sequence_number)
@@ -234,10 +193,6 @@ int cifs_verify_signature(struct smb_rqst *rqst,
234193
char what_we_think_sig_should_be[20];
235194
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
236195

237-
if (rqst->rq_iov[0].iov_len != 4 ||
238-
rqst->rq_iov[0].iov_base + 4 != rqst->rq_iov[1].iov_base)
239-
return -EIO;
240-
241196
if (cifs_pdu == NULL || server == NULL)
242197
return -EINVAL;
243198

fs/smb/client/cifsfs.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@
2828
#include <linux/splice.h>
2929
#include <linux/uuid.h>
3030
#include <linux/xattr.h>
31+
#include <linux/mm.h>
32+
#include <linux/key-type.h>
3133
#include <uapi/linux/magic.h>
3234
#include <net/ipv6.h>
3335
#include "cifsfs.h"
3436
#include "cifspdu.h"
3537
#define DECLARE_GLOBALS_HERE
3638
#include "cifsglob.h"
3739
#include "cifsproto.h"
40+
#include "smb2proto.h"
3841
#include "cifs_debug.h"
3942
#include "cifs_fs_sb.h"
40-
#include <linux/mm.h>
41-
#include <linux/key-type.h>
4243
#include "cifs_spnego.h"
4344
#include "fscache.h"
4445
#ifdef CONFIG_CIFS_DFS_UPCALL
@@ -442,7 +443,7 @@ static struct kmem_cache *cifs_io_request_cachep;
442443
static struct kmem_cache *cifs_io_subrequest_cachep;
443444
mempool_t *cifs_sm_req_poolp;
444445
mempool_t *cifs_req_poolp;
445-
mempool_t *cifs_mid_poolp;
446+
mempool_t cifs_mid_pool;
446447
mempool_t cifs_io_request_pool;
447448
mempool_t cifs_io_subrequest_pool;
448449

@@ -1016,7 +1017,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
10161017
} else {
10171018
cifs_info("Attempting to mount %s\n", old_ctx->source);
10181019
}
1019-
10201020
cifs_sb = kzalloc(sizeof(*cifs_sb), GFP_KERNEL);
10211021
if (!cifs_sb)
10221022
return ERR_PTR(-ENOMEM);
@@ -1847,8 +1847,7 @@ static int init_mids(void)
18471847
return -ENOMEM;
18481848

18491849
/* 3 is a reasonable minimum number of simultaneous operations */
1850-
cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
1851-
if (cifs_mid_poolp == NULL) {
1850+
if (mempool_init_slab_pool(&cifs_mid_pool, 3, cifs_mid_cachep) < 0) {
18521851
kmem_cache_destroy(cifs_mid_cachep);
18531852
return -ENOMEM;
18541853
}
@@ -1858,7 +1857,7 @@ static int init_mids(void)
18581857

18591858
static void destroy_mids(void)
18601859
{
1861-
mempool_destroy(cifs_mid_poolp);
1860+
mempool_exit(&cifs_mid_pool);
18621861
kmem_cache_destroy(cifs_mid_cachep);
18631862
}
18641863

0 commit comments

Comments
 (0)