cifs: Allocate encryption header through kmalloc
[ Upstream commit 3946d0d04b
]
When encryption is used, smb2_transform_hdr is defined on the stack and is
passed to the transport. This doesn't work with RDMA as the buffer needs to
be DMA'ed.
Fix it by using kmalloc.
Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6ba010ea48
commit
23e2519760
|
@ -466,7 +466,7 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
|
||||||
struct smb_rqst *rqst, int flags)
|
struct smb_rqst *rqst, int flags)
|
||||||
{
|
{
|
||||||
struct kvec iov;
|
struct kvec iov;
|
||||||
struct smb2_transform_hdr tr_hdr;
|
struct smb2_transform_hdr *tr_hdr;
|
||||||
struct smb_rqst cur_rqst[MAX_COMPOUND];
|
struct smb_rqst cur_rqst[MAX_COMPOUND];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -476,28 +476,34 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
|
||||||
if (num_rqst > MAX_COMPOUND - 1)
|
if (num_rqst > MAX_COMPOUND - 1)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
memset(&cur_rqst[0], 0, sizeof(cur_rqst));
|
|
||||||
memset(&iov, 0, sizeof(iov));
|
|
||||||
memset(&tr_hdr, 0, sizeof(tr_hdr));
|
|
||||||
|
|
||||||
iov.iov_base = &tr_hdr;
|
|
||||||
iov.iov_len = sizeof(tr_hdr);
|
|
||||||
cur_rqst[0].rq_iov = &iov;
|
|
||||||
cur_rqst[0].rq_nvec = 1;
|
|
||||||
|
|
||||||
if (!server->ops->init_transform_rq) {
|
if (!server->ops->init_transform_rq) {
|
||||||
cifs_server_dbg(VFS, "Encryption requested but transform "
|
cifs_server_dbg(VFS, "Encryption requested but transform "
|
||||||
"callback is missing\n");
|
"callback is missing\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr_hdr = kmalloc(sizeof(*tr_hdr), GFP_NOFS);
|
||||||
|
if (!tr_hdr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
memset(&cur_rqst[0], 0, sizeof(cur_rqst));
|
||||||
|
memset(&iov, 0, sizeof(iov));
|
||||||
|
memset(tr_hdr, 0, sizeof(*tr_hdr));
|
||||||
|
|
||||||
|
iov.iov_base = tr_hdr;
|
||||||
|
iov.iov_len = sizeof(*tr_hdr);
|
||||||
|
cur_rqst[0].rq_iov = &iov;
|
||||||
|
cur_rqst[0].rq_nvec = 1;
|
||||||
|
|
||||||
rc = server->ops->init_transform_rq(server, num_rqst + 1,
|
rc = server->ops->init_transform_rq(server, num_rqst + 1,
|
||||||
&cur_rqst[0], rqst);
|
&cur_rqst[0], rqst);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
goto out;
|
||||||
|
|
||||||
rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]);
|
rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]);
|
||||||
smb3_free_compound_rqst(num_rqst, &cur_rqst[1]);
|
smb3_free_compound_rqst(num_rqst, &cur_rqst[1]);
|
||||||
|
out:
|
||||||
|
kfree(tr_hdr);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue