summaryrefslogtreecommitdiffstats
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorraj <raj@FreeBSD.org>2009-05-23 13:23:46 +0000
committerraj <raj@FreeBSD.org>2009-05-23 13:23:46 +0000
commit806a0172aa42f0653bc4948ac86d97313ea7e71b (patch)
treed344a2c7d96fe600c9074dce9e698b9db9d2e8c5 /sys/opencrypto
parent618ad83d35d2fa737d62a7814c73eabde5de62f8 (diff)
downloadFreeBSD-src-806a0172aa42f0653bc4948ac86d97313ea7e71b.zip
FreeBSD-src-806a0172aa42f0653bc4948ac86d97313ea7e71b.tar.gz
Fix cryptodev UIO creation.
Cryptodev uses UIO structure do get data from userspace and pass it to cryptographic engines. Initially UIO size is equal to size of data passed to engine, but if UIO is prepared for hash calculation an additional small space is created to hold result of operation. While creating space for the result, UIO I/O vector size is correctly extended, but uio_resid field in UIO structure is not modified. As bus_dma code uses uio_resid field to determine size of UIO DMA mapping, resulting mapping hasn't correct size. This leads to a crash if all the following conditions are met: 1. Hardware cryptographic accelerator writes result of hash operation using DMA. 2. Size of input data is less or equal than (n * PAGE_SIZE), 3. Size of input data plus size of hash result is grather than (n * PAGE_SIZE, where n is the same as in point 2. This patch fixes this problem by adding size of the extenstion to uio_resid field in UIO structure. Submitted by: Piotr Ziecik kosmo ! semihalf dot com Reviewed by: philip Obtained from: Semihalf
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/cryptodev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 73280cc..5f1331d 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -409,8 +409,10 @@ cryptodev_op(
cse->uio.uio_rw = UIO_WRITE;
cse->uio.uio_td = td;
cse->uio.uio_iov[0].iov_len = cop->len;
- if (cse->thash)
+ if (cse->thash) {
cse->uio.uio_iov[0].iov_len += cse->thash->hashsize;
+ cse->uio.uio_resid += cse->thash->hashsize;
+ }
cse->uio.uio_iov[0].iov_base = malloc(cse->uio.uio_iov[0].iov_len,
M_XDATA, M_WAITOK);
OpenPOWER on IntegriCloud