diff options
author | jhb <jhb@FreeBSD.org> | 2018-02-15 21:27:24 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2018-05-09 10:28:58 -0300 |
commit | 293707af843ce1b4208eed3b8427b72356ea06f0 (patch) | |
tree | 12e6ddcad414f565e12dc1ce2208b9aee97a9be2 /sys/opencrypto | |
parent | 61033f55dc6b6b9c295e0ade753c1d0b142ddd1b (diff) | |
download | FreeBSD-src-293707af843ce1b4208eed3b8427b72356ea06f0.zip FreeBSD-src-293707af843ce1b4208eed3b8427b72356ea06f0.tar.gz |
MFC 318090,319475: Use const with some read-only buffers in opencrypto APIs.
318090:
Use const with some read-only buffers in opencrypto APIs.
- Mark the source buffer for a copyback operation as const in the kernel
API.
- Use const with input-only buffers in crypto ioctl structures used with
/dev/crypto.
319475:
Fix some new errors and a warning in cryptotest.
- Use a new 'char *key' to allocate storage for keys and assign the
pointer to the session2_op 'const char *' members after the key is
initialized.
- Mark the 'find' variable used in crfind() static so that crfind()
doesn't return a pointer to stack garbage.
Sponsored by: Chelsio Communications
(cherry picked from commit 230aaab2e615703ad509454fe1b16ab8f69b411c)
Diffstat (limited to 'sys/opencrypto')
-rw-r--r-- | sys/opencrypto/criov.c | 4 | ||||
-rw-r--r-- | sys/opencrypto/cryptodev.h | 24 |
2 files changed, 15 insertions, 13 deletions
diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c index 499bfe3..71e395a 100644 --- a/sys/opencrypto/criov.c +++ b/sys/opencrypto/criov.c @@ -79,7 +79,7 @@ cuio_copydata(struct uio* uio, int off, int len, caddr_t cp) } void -cuio_copyback(struct uio* uio, int off, int len, caddr_t cp) +cuio_copyback(struct uio* uio, int off, int len, c_caddr_t cp) { struct iovec *iov = uio->uio_iov; int iol = uio->uio_iovcnt; @@ -155,7 +155,7 @@ cuio_apply(struct uio *uio, int off, int len, int (*f)(void *, void *, u_int), } void -crypto_copyback(int flags, caddr_t buf, int off, int size, caddr_t in) +crypto_copyback(int flags, caddr_t buf, int off, int size, c_caddr_t in) { if ((flags & CRYPTO_F_IMBUF) != 0) diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index 91bec56..3ca77c7 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -212,9 +212,9 @@ struct session_op { u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ u_int32_t keylen; /* cipher key */ - caddr_t key; + c_caddr_t key; int mackeylen; /* mac key */ - caddr_t mackey; + c_caddr_t mackey; u_int32_t ses; /* returns: session # */ }; @@ -224,9 +224,9 @@ struct session2_op { u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ u_int32_t keylen; /* cipher key */ - caddr_t key; + c_caddr_t key; int mackeylen; /* mac key */ - caddr_t mackey; + c_caddr_t mackey; u_int32_t ses; /* returns: session # */ int crid; /* driver id + flags (rw) */ @@ -241,9 +241,10 @@ struct crypt_op { u_int16_t flags; #define COP_F_BATCH 0x0008 /* Batch op if possible */ u_int len; - caddr_t src, dst; /* become iov[] inside kernel */ + c_caddr_t src; /* become iov[] inside kernel */ + caddr_t dst; caddr_t mac; /* must be big enough for chosen MAC */ - caddr_t iv; + c_caddr_t iv; }; /* op and flags the same as crypt_op */ @@ -254,10 +255,11 @@ struct crypt_aead { u_int len; u_int aadlen; u_int ivlen; - caddr_t src, dst; /* become iov[] inside kernel */ - caddr_t aad; /* additional authenticated data */ + c_caddr_t src; /* become iov[] inside kernel */ + caddr_t dst; + c_caddr_t aad; /* additional authenticated data */ caddr_t tag; /* must fit for chosen TAG length */ - caddr_t iv; + c_caddr_t iv; }; /* @@ -526,7 +528,7 @@ extern int crypto_devallowsoft; /* only use hardware crypto */ */ struct uio; extern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp); -extern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp); +extern void cuio_copyback(struct uio* uio, int off, int len, c_caddr_t cp); extern int cuio_getptr(struct uio *uio, int loc, int *off); extern int cuio_apply(struct uio *uio, int off, int len, int (*f)(void *, void *, u_int), void *arg); @@ -537,7 +539,7 @@ extern int crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iovptr, int *cnt, int *allocated); extern void crypto_copyback(int flags, caddr_t buf, int off, int size, - caddr_t in); + c_caddr_t in); extern void crypto_copydata(int flags, caddr_t buf, int off, int size, caddr_t out); extern int crypto_apply(int flags, caddr_t buf, int off, int len, |