Commit 7fb8986e authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Add capability to transform requests before sending

This will allow us to do protocol specific tranformations of packets
before sending to the server. For SMB3 it can be used to support
encryption.
Signed-off-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
parent b8f57ee8
...@@ -433,6 +433,11 @@ struct smb_version_operations { ...@@ -433,6 +433,11 @@ struct smb_version_operations {
bool (*dir_needs_close)(struct cifsFileInfo *); bool (*dir_needs_close)(struct cifsFileInfo *);
long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t, long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t,
loff_t); loff_t);
/* init transform request - used for encryption for now */
int (*init_transform_rq)(struct TCP_Server_Info *, struct smb_rqst *,
struct smb_rqst *);
/* free transform request */
void (*free_transform_rq)(struct smb_rqst *);
}; };
struct smb_version_values { struct smb_version_values {
...@@ -1475,7 +1480,9 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param, ...@@ -1475,7 +1480,9 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
#define CIFS_OBREAK_OP 0x0100 /* oplock break request */ #define CIFS_OBREAK_OP 0x0100 /* oplock break request */
#define CIFS_NEG_OP 0x0200 /* negotiate request */ #define CIFS_NEG_OP 0x0200 /* negotiate request */
#define CIFS_OP_MASK 0x0380 /* mask request type */ #define CIFS_OP_MASK 0x0380 /* mask request type */
#define CIFS_HAS_CREDITS 0x0400 /* already has credits */ #define CIFS_HAS_CREDITS 0x0400 /* already has credits */
#define CIFS_TRANSFORM_REQ 0x0800 /* transform request before sending */
/* Security Flags: indicate type of session setup needed */ /* Security Flags: indicate type of session setup needed */
#define CIFSSEC_MAY_SIGN 0x00001 #define CIFSSEC_MAY_SIGN 0x00001
......
This diff is collapsed.
...@@ -221,7 +221,7 @@ rqst_len(struct smb_rqst *rqst) ...@@ -221,7 +221,7 @@ rqst_len(struct smb_rqst *rqst)
} }
static int static int
smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
{ {
int rc; int rc;
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
...@@ -313,12 +313,27 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) ...@@ -313,12 +313,27 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
} }
static int static int
smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
{ {
struct smb_rqst rqst = { .rq_iov = iov, struct smb_rqst cur_rqst;
.rq_nvec = n_vec }; int rc;
if (!(flags & CIFS_TRANSFORM_REQ))
return __smb_send_rqst(server, rqst);
if (!server->ops->init_transform_rq ||
!server->ops->free_transform_rq) {
cifs_dbg(VFS, "Encryption requested but transform callbacks are missed\n");
return -EIO;
}
return smb_send_rqst(server, &rqst); rc = server->ops->init_transform_rq(server, &cur_rqst, rqst);
if (rc)
return rc;
rc = __smb_send_rqst(server, &cur_rqst);
server->ops->free_transform_rq(&cur_rqst);
return rc;
} }
int int
...@@ -326,13 +341,15 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer, ...@@ -326,13 +341,15 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
unsigned int smb_buf_length) unsigned int smb_buf_length)
{ {
struct kvec iov[2]; struct kvec iov[2];
struct smb_rqst rqst = { .rq_iov = iov,
.rq_nvec = 2 };
iov[0].iov_base = smb_buffer; iov[0].iov_base = smb_buffer;
iov[0].iov_len = 4; iov[0].iov_len = 4;
iov[1].iov_base = (char *)smb_buffer + 4; iov[1].iov_base = (char *)smb_buffer + 4;
iov[1].iov_len = smb_buf_length; iov[1].iov_len = smb_buf_length;
return smb_sendv(server, iov, 2); return __smb_send_rqst(server, &rqst);
} }
static int static int
...@@ -524,7 +541,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, ...@@ -524,7 +541,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
cifs_in_send_inc(server); cifs_in_send_inc(server);
rc = smb_send_rqst(server, rqst); rc = smb_send_rqst(server, rqst, flags);
cifs_in_send_dec(server); cifs_in_send_dec(server);
cifs_save_when_sent(mid); cifs_save_when_sent(mid);
...@@ -718,7 +735,7 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -718,7 +735,7 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
midQ->mid_state = MID_REQUEST_SUBMITTED; midQ->mid_state = MID_REQUEST_SUBMITTED;
cifs_in_send_inc(ses->server); cifs_in_send_inc(ses->server);
rc = smb_send_rqst(ses->server, rqst); rc = smb_send_rqst(ses->server, rqst, flags);
cifs_in_send_dec(ses->server); cifs_in_send_dec(ses->server);
cifs_save_when_sent(midQ); cifs_save_when_sent(midQ);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment