Skip to content

Commit d31e379

Browse files
committed
Merge tag '6.5-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: "Four small SMB3 client fixes: - two reconnect fixes (to address the case where non-default iocharset gets incorrectly overridden at reconnect with the default charset) - fix for NTLMSSP_AUTH request setting a flag incorrectly) - Add missing check for invalid tlink (tree connection) in ioctl" * tag '6.5-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: add missing return value check for cifs_sb_tlink smb3: do not set NTLMSSP_VERSION flag for negotiate not auth request cifs: fix charset issue in reconnection fs/nls: make load_nls() take a const parameter
2 parents b88e123 + a171eb5 commit d31e379

File tree

9 files changed

+20
-8
lines changed

9 files changed

+20
-8
lines changed

fs/nls/nls_base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ int unregister_nls(struct nls_table * nls)
272272
return -EINVAL;
273273
}
274274

275-
static struct nls_table *find_nls(char *charset)
275+
static struct nls_table *find_nls(const char *charset)
276276
{
277277
struct nls_table *nls;
278278
spin_lock(&nls_lock);
@@ -288,7 +288,7 @@ static struct nls_table *find_nls(char *charset)
288288
return nls;
289289
}
290290

291-
struct nls_table *load_nls(char *charset)
291+
struct nls_table *load_nls(const char *charset)
292292
{
293293
return try_then_request_module(find_nls(charset), "nls_%s", charset);
294294
}

fs/smb/client/cifsglob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ struct cifs_ses {
10621062
unsigned long chans_need_reconnect;
10631063
/* ========= end: protected by chan_lock ======== */
10641064
struct cifs_ses *dfs_root_ses;
1065+
struct nls_table *local_nls;
10651066
};
10661067

10671068
static inline bool

fs/smb/client/cifssmb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
129129
}
130130
spin_unlock(&server->srv_lock);
131131

132-
nls_codepage = load_nls_default();
132+
nls_codepage = ses->local_nls;
133133

134134
/*
135135
* need to prevent multiple threads trying to simultaneously
@@ -200,7 +200,6 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
200200
rc = -EAGAIN;
201201
}
202202

203-
unload_nls(nls_codepage);
204203
return rc;
205204
}
206205

fs/smb/client/connect.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,10 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
18421842
CIFS_MAX_PASSWORD_LEN))
18431843
return 0;
18441844
}
1845+
1846+
if (strcmp(ctx->local_nls->charset, ses->local_nls->charset))
1847+
return 0;
1848+
18451849
return 1;
18461850
}
18471851

@@ -2286,6 +2290,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
22862290

22872291
ses->sectype = ctx->sectype;
22882292
ses->sign = ctx->sign;
2293+
ses->local_nls = load_nls(ctx->local_nls->charset);
22892294

22902295
/* add server as first channel */
22912296
spin_lock(&ses->chan_lock);

fs/smb/client/ioctl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
478478
}
479479
cifs_sb = CIFS_SB(inode->i_sb);
480480
tlink = cifs_sb_tlink(cifs_sb);
481+
if (IS_ERR(tlink)) {
482+
rc = PTR_ERR(tlink);
483+
break;
484+
}
485+
481486
tcon = tlink_tcon(tlink);
482487
rc = cifs_dump_full_key(tcon, (void __user *)arg);
483488
cifs_put_tlink(tlink);

fs/smb/client/misc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ sesInfoFree(struct cifs_ses *buf_to_free)
9595
return;
9696
}
9797

98+
unload_nls(buf_to_free->local_nls);
9899
atomic_dec(&sesInfoAllocCount);
99100
kfree(buf_to_free->serverOS);
100101
kfree(buf_to_free->serverDomain);

fs/smb/client/sess.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ int build_ntlmssp_smb3_negotiate_blob(unsigned char **pbuffer,
10131013
}
10141014

10151015

1016+
/* See MS-NLMP 2.2.1.3 */
10161017
int build_ntlmssp_auth_blob(unsigned char **pbuffer,
10171018
u16 *buflen,
10181019
struct cifs_ses *ses,
@@ -1047,7 +1048,8 @@ int build_ntlmssp_auth_blob(unsigned char **pbuffer,
10471048

10481049
flags = ses->ntlmssp->server_flags | NTLMSSP_REQUEST_TARGET |
10491050
NTLMSSP_NEGOTIATE_TARGET_INFO | NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED;
1050-
1051+
/* we only send version information in ntlmssp negotiate, so do not set this flag */
1052+
flags = flags & ~NTLMSSP_NEGOTIATE_VERSION;
10511053
tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE);
10521054
sec_blob->NegotiateFlags = cpu_to_le32(flags);
10531055

fs/smb/client/smb2pdu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
242242
}
243243
spin_unlock(&server->srv_lock);
244244

245-
nls_codepage = load_nls_default();
245+
nls_codepage = ses->local_nls;
246246

247247
/*
248248
* need to prevent multiple threads trying to simultaneously
@@ -324,7 +324,6 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
324324
rc = -EAGAIN;
325325
}
326326
failed:
327-
unload_nls(nls_codepage);
328327
return rc;
329328
}
330329

include/linux/nls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum utf16_endian {
4747
/* nls_base.c */
4848
extern int __register_nls(struct nls_table *, struct module *);
4949
extern int unregister_nls(struct nls_table *);
50-
extern struct nls_table *load_nls(char *);
50+
extern struct nls_table *load_nls(const char *charset);
5151
extern void unload_nls(struct nls_table *);
5252
extern struct nls_table *load_nls_default(void);
5353
#define register_nls(nls) __register_nls((nls), THIS_MODULE)

0 commit comments

Comments
 (0)