Skip to content

Commit b7a838e

Browse files
committed
Merge tag 'v6.12-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - statfs fix (e.g. when limited access to root directory of share) - special file handling fixes: fix packet validation to avoid buffer overflow for reparse points, fixes for symlink path parsing (one for reparse points, and one for SFU use case), and fix for cleanup after failed SET_REPARSE operation. - fix for SMB2.1 signing bug introduced by recent patch to NFS symlink path, and NFS reparse point validation - comment cleanup * tag 'v6.12-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: Do not convert delimiter when parsing NFS-style symlinks cifs: Validate content of NFS reparse point buffer cifs: Fix buffer overflow when parsing NFS reparse points smb: client: Correct typos in multiple comments across various files smb: client: use actual path when queryfs cifs: Remove intermediate object of failed create reparse call Revert "smb: client: make SHA-512 TFM ephemeral" smb: Update comments about some reparse point tags cifs: Check for UTF-16 null codepoint in SFU symlink target location
2 parents 6cca119 + d3a49f6 commit b7a838e

24 files changed

+167
-59
lines changed

fs/smb/client/cifsacl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct smb3_sd {
5555
#define ACL_CONTROL_SI 0x0800 /* SACL Auto-Inherited */
5656
#define ACL_CONTROL_DI 0x0400 /* DACL Auto-Inherited */
5757
#define ACL_CONTROL_SC 0x0200 /* SACL computed through inheritance */
58-
#define ACL_CONTROL_DC 0x0100 /* DACL computed through inheritence */
58+
#define ACL_CONTROL_DC 0x0100 /* DACL computed through inheritance */
5959
#define ACL_CONTROL_SS 0x0080 /* Create server ACL */
6060
#define ACL_CONTROL_DT 0x0040 /* DACL provided by trusted source */
6161
#define ACL_CONTROL_SD 0x0020 /* SACL defaulted */

fs/smb/client/cifsencrypt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int cifs_verify_signature(struct smb_rqst *rqst,
239239
cifs_dbg(FYI, "dummy signature received for smb command 0x%x\n",
240240
cifs_pdu->Command);
241241

242-
/* save off the origiginal signature so we can modify the smb and check
242+
/* save off the original signature so we can modify the smb and check
243243
its signature against what the server sent */
244244
memcpy(server_response_sig, cifs_pdu->Signature.SecuritySignature, 8);
245245

@@ -700,6 +700,7 @@ cifs_crypto_secmech_release(struct TCP_Server_Info *server)
700700
cifs_free_hash(&server->secmech.aes_cmac);
701701
cifs_free_hash(&server->secmech.hmacsha256);
702702
cifs_free_hash(&server->secmech.md5);
703+
cifs_free_hash(&server->secmech.sha512);
703704

704705
if (!SERVER_IS_CHAN(server)) {
705706
if (server->secmech.enc) {

fs/smb/client/cifsfs.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ __u32 cifs_lock_secret;
161161

162162
/*
163163
* Bumps refcount for cifs super block.
164-
* Note that it should be only called if a referece to VFS super block is
164+
* Note that it should be only called if a reference to VFS super block is
165165
* already held, e.g. in open-type syscalls context. Otherwise it can race with
166166
* atomic_dec_and_test in deactivate_locked_super.
167167
*/
@@ -289,7 +289,7 @@ static void cifs_kill_sb(struct super_block *sb)
289289
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
290290

291291
/*
292-
* We ned to release all dentries for the cached directories
292+
* We need to release all dentries for the cached directories
293293
* before we kill the sb.
294294
*/
295295
if (cifs_sb->root) {
@@ -313,8 +313,17 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
313313
struct TCP_Server_Info *server = tcon->ses->server;
314314
unsigned int xid;
315315
int rc = 0;
316+
const char *full_path;
317+
void *page;
316318

317319
xid = get_xid();
320+
page = alloc_dentry_path();
321+
322+
full_path = build_path_from_dentry(dentry, page);
323+
if (IS_ERR(full_path)) {
324+
rc = PTR_ERR(full_path);
325+
goto statfs_out;
326+
}
318327

319328
if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0)
320329
buf->f_namelen =
@@ -330,8 +339,10 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
330339
buf->f_ffree = 0; /* unlimited */
331340

332341
if (server->ops->queryfs)
333-
rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
342+
rc = server->ops->queryfs(xid, tcon, full_path, cifs_sb, buf);
334343

344+
statfs_out:
345+
free_dentry_path(page);
335346
free_xid(xid);
336347
return rc;
337348
}

fs/smb/client/cifsglob.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ struct session_key {
180180
struct cifs_secmech {
181181
struct shash_desc *md5; /* md5 hash function, for CIFS/SMB1 signatures */
182182
struct shash_desc *hmacsha256; /* hmac-sha256 hash function, for SMB2 signatures */
183+
struct shash_desc *sha512; /* sha512 hash function, for SMB3.1.1 preauth hash */
183184
struct shash_desc *aes_cmac; /* block-cipher based MAC function, for SMB3 signatures */
184185

185186
struct crypto_aead *enc; /* smb3 encryption AEAD TFM (AES-CCM and AES-GCM) */
@@ -480,7 +481,7 @@ struct smb_version_operations {
480481
__u16 net_fid, struct cifsInodeInfo *cifs_inode);
481482
/* query remote filesystem */
482483
int (*queryfs)(const unsigned int, struct cifs_tcon *,
483-
struct cifs_sb_info *, struct kstatfs *);
484+
const char *, struct cifs_sb_info *, struct kstatfs *);
484485
/* send mandatory brlock to the server */
485486
int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
486487
__u64, __u32, int, int, bool);
@@ -774,7 +775,7 @@ struct TCP_Server_Info {
774775
} compression;
775776
__u16 signing_algorithm;
776777
__le16 cipher_type;
777-
/* save initital negprot hash */
778+
/* save initial negprot hash */
778779
__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
779780
bool signing_negotiated; /* true if valid signing context rcvd from server */
780781
bool posix_ext_supported;

fs/smb/client/cifspdu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ typedef struct smb_com_logoff_andx_rsp {
781781
__u16 ByteCount;
782782
} __attribute__((packed)) LOGOFF_ANDX_RSP;
783783

784-
typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
784+
typedef union smb_com_tree_disconnect { /* as an alternative can use flag on
785785
tree_connect PDU to effect disconnect */
786786
/* tdis is probably simplest SMB PDU */
787787
struct {
@@ -2406,7 +2406,7 @@ struct cifs_posix_ace { /* access control entry (ACE) */
24062406
__le64 cifs_uid; /* or gid */
24072407
} __attribute__((packed));
24082408

2409-
struct cifs_posix_acl { /* access conrol list (ACL) */
2409+
struct cifs_posix_acl { /* access control list (ACL) */
24102410
__le16 version;
24112411
__le16 access_entry_count; /* access ACL - count of entries */
24122412
__le16 default_entry_count; /* default ACL - count of entries */

fs/smb/client/cifssmb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
12151215
req->CreateDisposition = cpu_to_le32(disposition);
12161216
req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
12171217

1218-
/* BB Expirement with various impersonation levels and verify */
1218+
/* BB Experiment with various impersonation levels and verify */
12191219
req->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION);
12201220
req->SecurityFlags = SECURITY_CONTEXT_TRACKING|SECURITY_EFFECTIVE_ONLY;
12211221

@@ -3018,7 +3018,7 @@ static void cifs_init_ace(struct cifs_posix_ace *cifs_ace,
30183018

30193019
/**
30203020
* posix_acl_to_cifs - convert ACLs from POSIX ACL to cifs format
3021-
* @parm_data: ACLs in cifs format to conver to
3021+
* @parm_data: ACLs in cifs format to convert to
30223022
* @acl: ACLs in POSIX ACL format to convert from
30233023
* @acl_type: the type of POSIX ACLs stored in @acl
30243024
*
@@ -3995,7 +3995,7 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
39953995
name_len =
39963996
cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName,
39973997
PATH_MAX, nls_codepage, remap);
3998-
/* We can not add the asterik earlier in case
3998+
/* We can not add the asterisk earlier in case
39993999
it got remapped to 0xF03A as if it were part of the
40004000
directory name instead of a wildcard */
40014001
name_len *= 2;

fs/smb/client/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
25022502
}
25032503
}
25042504
}
2505-
/* couldn't find useable FH with same pid, try any available */
2505+
/* couldn't find usable FH with same pid, try any available */
25062506
if (!any_available) {
25072507
any_available = true;
25082508
goto refind_writable;

fs/smb/client/fs_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ struct smb3_fs_context {
260260
unsigned int min_offload;
261261
unsigned int retrans;
262262
bool sockopt_tcp_nodelay:1;
263-
/* attribute cache timemout for files and directories in jiffies */
263+
/* attribute cache timeout for files and directories in jiffies */
264264
unsigned long acregmax;
265265
unsigned long acdirmax;
266266
/* timeout for deferred close of files in jiffies */

fs/smb/client/inode.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,16 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
629629
&symlink_len_utf16,
630630
&symlink_buf_utf16,
631631
&buf_type);
632+
/*
633+
* Check that read buffer has valid length and does not
634+
* contain UTF-16 null codepoint (via UniStrnlen() call)
635+
* because Linux cannot process symlink with null byte.
636+
*/
632637
if ((rc == 0) &&
633638
(symlink_len_utf16 > 0) &&
634639
(symlink_len_utf16 < fattr->cf_eof-8 + 1) &&
635-
(symlink_len_utf16 % 2 == 0)) {
640+
(symlink_len_utf16 % 2 == 0) &&
641+
(UniStrnlen((wchar_t *)symlink_buf_utf16, symlink_len_utf16/2) == symlink_len_utf16/2)) {
636642
fattr->cf_symlink_target =
637643
cifs_strndup_from_utf16(symlink_buf_utf16,
638644
symlink_len_utf16,

fs/smb/client/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ free_rsp_buf(int resp_buftype, void *rsp)
254254
}
255255

256256
/* NB: MID can not be set if treeCon not passed in, in that
257-
case it is responsbility of caller to set the mid */
257+
case it is responsibility of caller to set the mid */
258258
void
259259
header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
260260
const struct cifs_tcon *treeCon, int word_count

0 commit comments

Comments
 (0)