Skip to content

Commit 04faac1

Browse files
committed
Merge tag '4.19-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Three small SMB3 fixes, one for stable" * tag '4.19-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6: cifs: update internal module version number for cifs.ko to 2.12 cifs: check kmalloc before use cifs: check if SMB2 PDU size has been padded and suppress the warning cifs: create a define for how many iovs we need for an SMB2_open()
2 parents 1b2de5d + 7753e38 commit 04faac1

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

fs/cifs/cifsfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
148148
extern const struct export_operations cifs_export_ops;
149149
#endif /* CONFIG_CIFS_NFSD_EXPORT */
150150

151-
#define CIFS_VERSION "2.12"
151+
#define CIFS_VERSION "2.13"
152152
#endif /* _CIFSFS_H */

fs/cifs/sess.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ int build_ntlmssp_auth_blob(unsigned char **pbuffer,
398398
goto setup_ntlmv2_ret;
399399
}
400400
*pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL);
401+
if (!*pbuffer) {
402+
rc = -ENOMEM;
403+
cifs_dbg(VFS, "Error %d during NTLMSSP allocation\n", rc);
404+
*buflen = 0;
405+
goto setup_ntlmv2_ret;
406+
}
401407
sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer;
402408

403409
memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);

fs/cifs/smb2misc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
237237
if (clc_len == len + 1)
238238
return 0;
239239

240+
/*
241+
* Some windows servers (win2016) will pad also the final
242+
* PDU in a compound to 8 bytes.
243+
*/
244+
if (((clc_len + 7) & ~7) == len)
245+
return 0;
246+
240247
/*
241248
* MacOS server pads after SMB2.1 write response with 3 bytes
242249
* of junk. Other servers match RFC1001 len to actual

fs/cifs/smb2ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
15821582
struct smb_rqst rqst[3];
15831583
int resp_buftype[3];
15841584
struct kvec rsp_iov[3];
1585-
struct kvec open_iov[5]; /* 4 + potential padding. */
1585+
struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
15861586
struct kvec qi_iov[1];
15871587
struct kvec close_iov[1];
15881588
struct cifs_ses *ses = tcon->ses;
@@ -1603,7 +1603,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
16031603

16041604
memset(&open_iov, 0, sizeof(open_iov));
16051605
rqst[0].rq_iov = open_iov;
1606-
rqst[0].rq_nvec = 4;
1606+
rqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE;
16071607

16081608
oparms.tcon = tcon;
16091609
oparms.desired_access = FILE_READ_ATTRIBUTES;

fs/cifs/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
22562256
struct TCP_Server_Info *server;
22572257
struct cifs_tcon *tcon = oparms->tcon;
22582258
struct cifs_ses *ses = tcon->ses;
2259-
struct kvec iov[5]; /* make sure at least one for each open context */
2259+
struct kvec iov[SMB2_CREATE_IOV_SIZE];
22602260
struct kvec rsp_iov = {NULL, 0};
22612261
int resp_buftype;
22622262
int rc = 0;
@@ -2274,7 +2274,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
22742274
memset(&rqst, 0, sizeof(struct smb_rqst));
22752275
memset(&iov, 0, sizeof(iov));
22762276
rqst.rq_iov = iov;
2277-
rqst.rq_nvec = 5;
2277+
rqst.rq_nvec = SMB2_CREATE_IOV_SIZE;
22782278

22792279
rc = SMB2_open_init(tcon, &rqst, oplock, oparms, path);
22802280
if (rc)

fs/cifs/smb2pdu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,18 @@ struct smb2_tree_disconnect_rsp {
614614
#define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
615615

616616

617+
/*
618+
* Maximum number of iovs we need for an open/create request.
619+
* [0] : struct smb2_create_req
620+
* [1] : path
621+
* [2] : lease context
622+
* [3] : durable context
623+
* [4] : posix context
624+
* [5] : time warp context
625+
* [6] : compound padding
626+
*/
627+
#define SMB2_CREATE_IOV_SIZE 7
628+
617629
struct smb2_create_req {
618630
struct smb2_sync_hdr sync_hdr;
619631
__le16 StructureSize; /* Must be 57 */

0 commit comments

Comments
 (0)