Skip to content

Commit 327a8d7

Browse files
committed
Merge tag '5.9-rc-smb3-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs updates from Steve French: "16 cifs/smb3 fixes, about half DFS related, two fixes for stable. Still working on and testing an additional set of fixes (including updates to mount, and some fallocate scenario improvements) for later in the merge window" * tag '5.9-rc-smb3-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6: cifs: document and cleanup dfs mount cifs: only update prefix path of DFS links in cifs_tree_connect() cifs: fix double free error on share and prefix cifs: handle RESP_GET_DFS_REFERRAL.PathConsumed in reconnect cifs: handle empty list of targets in cifs_reconnect() cifs: rename reconn_inval_dfs_target() cifs: reduce number of referral requests in DFS link lookups cifs: merge __{cifs,smb2}_reconnect[_tcon]() into cifs_tree_connect() cifs: convert to use be32_add_cpu() cifs: delete duplicated words in header files cifs: Remove the superfluous break cifs: smb1: Try failing back to SetFileInfo if SetPathInfo fails cifs`: handle ERRBaduid for SMB1 cifs: remove unused variable 'server' smb3: warn on confusing error scenario with sec=krb5 cifs: Fix leak when handling lease break for cached root fid
2 parents 96e3f3c + 7efd081 commit 327a8d7

File tree

16 files changed

+560
-493
lines changed

16 files changed

+560
-493
lines changed

fs/cifs/cifsacl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ struct cifs_ace {
132132
/*
133133
* The current SMB3 form of security descriptor is similar to what was used for
134134
* cifs (see above) but some fields are split, and fields in the struct below
135-
* matches names of fields to the the spec, MS-DTYP (see sections 2.4.5 and
135+
* matches names of fields to the spec, MS-DTYP (see sections 2.4.5 and
136136
* 2.4.6). Note that "CamelCase" fields are used in this struct in order to
137137
* match the MS-DTYP and MS-SMB2 specs which define the wire format.
138138
*/
@@ -178,7 +178,7 @@ struct smb3_acl {
178178

179179
/*
180180
* Used to store the special 'NFS SIDs' used to persist the POSIX uid and gid
181-
* See See http://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx
181+
* See http://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx
182182
*/
183183
struct owner_sid {
184184
u8 Revision;

fs/cifs/cifsglob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ struct cifsInodeInfo {
14661466
struct list_head llist; /* locks helb by this inode */
14671467
/*
14681468
* NOTE: Some code paths call down_read(lock_sem) twice, so
1469-
* we must always use use cifs_down_write() instead of down_write()
1469+
* we must always use cifs_down_write() instead of down_write()
14701470
* for this semaphore to avoid deadlocks.
14711471
*/
14721472
struct rw_semaphore lock_sem; /* protect the fields above */

fs/cifs/cifsproto.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ extern int decode_negTokenInit(unsigned char *security_blob, int length,
154154
extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
155155
extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
156156
extern int map_smb_to_linux_error(char *buf, bool logErr);
157+
extern int map_and_check_smb_error(struct mid_q_entry *mid, bool logErr);
157158
extern void header_assemble(struct smb_hdr *, char /* command */ ,
158159
const struct cifs_tcon *, int /* length of
159160
fixed section (word count) in two byte units */);
@@ -271,6 +272,9 @@ extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
271272
extern void cifs_free_llist(struct list_head *llist);
272273
extern void cifs_del_lock_waiters(struct cifsLockInfo *lock);
273274

275+
extern int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon,
276+
const struct nls_table *nlsc);
277+
274278
extern int cifs_negotiate_protocol(const unsigned int xid,
275279
struct cifs_ses *ses);
276280
extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
@@ -344,7 +348,7 @@ extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
344348
extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
345349
const char *fileName, const FILE_BASIC_INFO *data,
346350
const struct nls_table *nls_codepage,
347-
int remap_special_chars);
351+
struct cifs_sb_info *cifs_sb);
348352
extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
349353
const FILE_BASIC_INFO *data, __u16 fid,
350354
__u32 pid_of_opener);
@@ -613,8 +617,7 @@ int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,
613617

614618
struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
615619
void cifs_put_tcp_super(struct super_block *sb);
616-
int update_super_prepath(struct cifs_tcon *tcon, const char *prefix,
617-
size_t prefix_len);
620+
int update_super_prepath(struct cifs_tcon *tcon, char *prefix);
618621

619622
#ifdef CONFIG_CIFS_DFS_UPCALL
620623
static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,

fs/cifs/cifssmb.c

Lines changed: 39 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -124,116 +124,6 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)
124124
*/
125125
}
126126

127-
#ifdef CONFIG_CIFS_DFS_UPCALL
128-
static int __cifs_reconnect_tcon(const struct nls_table *nlsc,
129-
struct cifs_tcon *tcon)
130-
{
131-
int rc;
132-
struct TCP_Server_Info *server = tcon->ses->server;
133-
struct dfs_cache_tgt_list tl;
134-
struct dfs_cache_tgt_iterator *it = NULL;
135-
char *tree;
136-
const char *tcp_host;
137-
size_t tcp_host_len;
138-
const char *dfs_host;
139-
size_t dfs_host_len;
140-
141-
tree = kzalloc(MAX_TREE_SIZE, GFP_KERNEL);
142-
if (!tree)
143-
return -ENOMEM;
144-
145-
if (!tcon->dfs_path) {
146-
if (tcon->ipc) {
147-
scnprintf(tree, MAX_TREE_SIZE, "\\\\%s\\IPC$",
148-
server->hostname);
149-
rc = CIFSTCon(0, tcon->ses, tree, tcon, nlsc);
150-
} else {
151-
rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, nlsc);
152-
}
153-
goto out;
154-
}
155-
156-
rc = dfs_cache_noreq_find(tcon->dfs_path + 1, NULL, &tl);
157-
if (rc)
158-
goto out;
159-
160-
extract_unc_hostname(server->hostname, &tcp_host, &tcp_host_len);
161-
162-
for (it = dfs_cache_get_tgt_iterator(&tl); it;
163-
it = dfs_cache_get_next_tgt(&tl, it)) {
164-
const char *share, *prefix;
165-
size_t share_len, prefix_len;
166-
bool target_match;
167-
168-
rc = dfs_cache_get_tgt_share(it, &share, &share_len, &prefix,
169-
&prefix_len);
170-
if (rc) {
171-
cifs_dbg(VFS, "%s: failed to parse target share %d\n",
172-
__func__, rc);
173-
continue;
174-
}
175-
176-
extract_unc_hostname(share, &dfs_host, &dfs_host_len);
177-
178-
if (dfs_host_len != tcp_host_len
179-
|| strncasecmp(dfs_host, tcp_host, dfs_host_len) != 0) {
180-
cifs_dbg(FYI, "%s: %.*s doesn't match %.*s\n",
181-
__func__,
182-
(int)dfs_host_len, dfs_host,
183-
(int)tcp_host_len, tcp_host);
184-
185-
rc = match_target_ip(server, dfs_host, dfs_host_len,
186-
&target_match);
187-
if (rc) {
188-
cifs_dbg(VFS, "%s: failed to match target ip: %d\n",
189-
__func__, rc);
190-
break;
191-
}
192-
193-
if (!target_match) {
194-
cifs_dbg(FYI, "%s: skipping target\n", __func__);
195-
continue;
196-
}
197-
}
198-
199-
if (tcon->ipc) {
200-
scnprintf(tree, MAX_TREE_SIZE, "\\\\%.*s\\IPC$",
201-
(int)share_len, share);
202-
rc = CIFSTCon(0, tcon->ses, tree, tcon, nlsc);
203-
} else {
204-
scnprintf(tree, MAX_TREE_SIZE, "\\%.*s", (int)share_len,
205-
share);
206-
rc = CIFSTCon(0, tcon->ses, tree, tcon, nlsc);
207-
if (!rc) {
208-
rc = update_super_prepath(tcon, prefix,
209-
prefix_len);
210-
break;
211-
}
212-
}
213-
if (rc == -EREMOTE)
214-
break;
215-
}
216-
217-
if (!rc) {
218-
if (it)
219-
rc = dfs_cache_noreq_update_tgthint(tcon->dfs_path + 1,
220-
it);
221-
else
222-
rc = -ENOENT;
223-
}
224-
dfs_cache_free_tgts(&tl);
225-
out:
226-
kfree(tree);
227-
return rc;
228-
}
229-
#else
230-
static inline int __cifs_reconnect_tcon(const struct nls_table *nlsc,
231-
struct cifs_tcon *tcon)
232-
{
233-
return CIFSTCon(0, tcon->ses, tcon->treeName, tcon, nlsc);
234-
}
235-
#endif
236-
237127
/* reconnect the socket, tcon, and smb session if needed */
238128
static int
239129
cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
@@ -338,7 +228,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
338228
}
339229

340230
cifs_mark_open_files_invalid(tcon);
341-
rc = __cifs_reconnect_tcon(nls_codepage, tcon);
231+
rc = cifs_tree_connect(0, tcon, nls_codepage);
342232
mutex_unlock(&ses->session_mutex);
343233
cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
344234

@@ -5913,10 +5803,42 @@ CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
59135803
return rc;
59145804
}
59155805

5806+
static int
5807+
CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
5808+
const char *fileName, const FILE_BASIC_INFO *data,
5809+
const struct nls_table *nls_codepage,
5810+
struct cifs_sb_info *cifs_sb)
5811+
{
5812+
int oplock = 0;
5813+
struct cifs_open_parms oparms;
5814+
struct cifs_fid fid;
5815+
int rc;
5816+
5817+
oparms.tcon = tcon;
5818+
oparms.cifs_sb = cifs_sb;
5819+
oparms.desired_access = GENERIC_WRITE;
5820+
oparms.create_options = cifs_create_options(cifs_sb, 0);
5821+
oparms.disposition = FILE_OPEN;
5822+
oparms.path = fileName;
5823+
oparms.fid = &fid;
5824+
oparms.reconnect = false;
5825+
5826+
rc = CIFS_open(xid, &oparms, &oplock, NULL);
5827+
if (rc)
5828+
goto out;
5829+
5830+
rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
5831+
CIFSSMBClose(xid, tcon, fid.netfid);
5832+
out:
5833+
5834+
return rc;
5835+
}
5836+
59165837
int
59175838
CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59185839
const char *fileName, const FILE_BASIC_INFO *data,
5919-
const struct nls_table *nls_codepage, int remap)
5840+
const struct nls_table *nls_codepage,
5841+
struct cifs_sb_info *cifs_sb)
59205842
{
59215843
TRANSACTION2_SPI_REQ *pSMB = NULL;
59225844
TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -5925,6 +5847,7 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59255847
int bytes_returned = 0;
59265848
char *data_offset;
59275849
__u16 params, param_offset, offset, byte_count, count;
5850+
int remap = cifs_remap(cifs_sb);
59285851

59295852
cifs_dbg(FYI, "In SetTimes\n");
59305853

@@ -5987,6 +5910,10 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
59875910
if (rc == -EAGAIN)
59885911
goto SetTimesRetry;
59895912

5913+
if (rc == -EOPNOTSUPP)
5914+
return CIFSSMBSetPathInfoFB(xid, tcon, fileName, data,
5915+
nls_codepage, cifs_sb);
5916+
59905917
return rc;
59915918
}
59925919

0 commit comments

Comments
 (0)