Commit 15e7b6d7 authored by Steve French's avatar Steve French
Browse files

smb3: move defines for ioctl protocol header and SMB2 sizes to smbfs_common



The definitions for the ioctl SMB3 request and response as well
as length of various fields defined in the protocol documentation
were duplicated in fs/ksmbd and fs/cifs.  Move these to the common
code in fs/smbfs_common/smb2pdu.h

Reviewed-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 113be37d
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -852,13 +852,7 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
#define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
#define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)

/*
 * The default wsize is 1M. find_get_pages seems to return a maximum of 256
 * pages in a single call. With PAGE_SIZE == 4k, this means we can fill
 * a single wsize request with a single call.
 */
#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
#define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)

/*
 * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
+0 −12
Original line number Diff line number Diff line
@@ -123,18 +123,6 @@
 */
#define CIFS_SESS_KEY_SIZE (16)

/*
 * Size of the smb3 signing key
 */
#define SMB3_SIGN_KEY_SIZE (16)

/*
 * Size of the smb3 encryption/decryption key storage.
 * This size is big enough to store any cipher key types.
 */
#define SMB3_ENC_DEC_KEY_SIZE (32)

#define CIFS_CLIENT_CHALLENGE_SIZE (8)
#define CIFS_SERVER_CHALLENGE_SIZE (8)
#define CIFS_HMAC_MD5_HASH_SIZE (16)
#define CIFS_CPHTXT_SIZE (16)
+0 −11
Original line number Diff line number Diff line
@@ -41,15 +41,4 @@
#define END_OF_CHAIN 4
#define RELATED_REQUEST 8

#define SMB2_SIGNATURE_SIZE (16)
#define SMB2_NTLMV2_SESSKEY_SIZE (16)
#define SMB2_HMACSHA256_SIZE (32)
#define SMB2_CMACAES_SIZE (16)
#define SMB3_SIGNKEY_SIZE (16)
#define SMB3_GCM128_CRYPTKEY_SIZE (16)
#define SMB3_GCM256_CRYPTKEY_SIZE (32)

/* Maximum buffer size value we can send with 1 credit */
#define SMB2_MAX_BUFFER_SIZE 65536

#endif	/* _SMB2_GLOB_H */
+0 −41
Original line number Diff line number Diff line
@@ -141,13 +141,6 @@ struct create_durable {
	} Data;
} __packed;

struct create_posix {
	struct create_context ccontext;
	__u8	Name[16];
	__le32  Mode;
	__u32	Reserved;
} __packed;

/* See MS-SMB2 2.2.13.2.11 */
/* Flags */
#define SMB2_DHANDLE_FLAG_PERSISTENT	0x00000002
@@ -428,40 +421,6 @@ struct duplicate_extents_to_file {
 */
#define SMB2_IOCTL_IOV_SIZE 2

struct smb2_ioctl_req {
	struct smb2_hdr hdr;
	__le16 StructureSize;	/* Must be 57 */
	__u16 Reserved;
	__le32 CtlCode;
	__u64  PersistentFileId; /* opaque endianness */
	__u64  VolatileFileId; /* opaque endianness */
	__le32 InputOffset;
	__le32 InputCount;
	__le32 MaxInputResponse;
	__le32 OutputOffset;
	__le32 OutputCount;
	__le32 MaxOutputResponse;
	__le32 Flags;
	__u32  Reserved2;
	__u8   Buffer[];
} __packed;

struct smb2_ioctl_rsp {
	struct smb2_hdr hdr;
	__le16 StructureSize;	/* Must be 57 */
	__u16 Reserved;
	__le32 CtlCode;
	__u64  PersistentFileId; /* opaque endianness */
	__u64  VolatileFileId; /* opaque endianness */
	__le32 InputOffset;
	__le32 InputCount;
	__le32 OutputOffset;
	__le32 OutputCount;
	__le32 Flags;
	__u32  Reserved2;
	/* char * buffer[] */
} __packed;

#define SMB2_LOCKFLAG_SHARED_LOCK	0x0001
#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK	0x0002
#define SMB2_LOCKFLAG_UNLOCK		0x0004
+3 −3
Original line number Diff line number Diff line
@@ -7581,7 +7581,7 @@ int smb2_ioctl(struct ksmbd_work *work)
		goto out;
	}

	cnt_code = le32_to_cpu(req->CntCode);
	cnt_code = le32_to_cpu(req->CtlCode);
	ret = smb2_calc_max_out_buf_len(work, 48,
					le32_to_cpu(req->MaxOutputResponse));
	if (ret < 0) {
@@ -7687,7 +7687,7 @@ int smb2_ioctl(struct ksmbd_work *work)
		rsp->PersistentFileId = req->PersistentFileId;
		fsctl_copychunk(work,
				(struct copychunk_ioctl_req *)&req->Buffer[0],
				le32_to_cpu(req->CntCode),
				le32_to_cpu(req->CtlCode),
				le32_to_cpu(req->InputCount),
				req->VolatileFileId,
				req->PersistentFileId,
@@ -7841,7 +7841,7 @@ int smb2_ioctl(struct ksmbd_work *work)
		goto out;
	}

	rsp->CntCode = cpu_to_le32(cnt_code);
	rsp->CtlCode = cpu_to_le32(cnt_code);
	rsp->InputCount = cpu_to_le32(0);
	rsp->InputOffset = cpu_to_le32(112);
	rsp->OutputOffset = cpu_to_le32(112);
Loading