summaryrefslogtreecommitdiff
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2004-11-17 09:09:55 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2004-11-17 09:09:55 +0000
commita0fbccc9e7e76341ed2e8313175195d0a17a3d86 (patch)
tree3e96ca6c2f3203ce32ec61d3746561cf0c4bd761 /sys/opencrypto
parentdb446e30cc9be65ecfd58882ca931983785ec5f4 (diff)
Notes
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/cryptodev.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 9b0da7ce3026..b9d26a9d1740 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -147,6 +147,10 @@ cryptof_ioctl(
u_int32_t ses;
int error = 0;
+ /*
+ * XXX: Not sure Giant is needed, but better safe than sorry
+ */
+ mtx_lock(&Giant);
switch (cmd) {
case CIOCGSESSION:
sop = (struct session_op *)data;
@@ -178,6 +182,7 @@ cryptof_ioctl(
txform = &enc_xform_arc4;
break;
default:
+ mtx_unlock(&Giant);
return (EINVAL);
}
@@ -197,8 +202,10 @@ cryptof_ioctl(
thash = &auth_hash_hmac_sha2_384;
else if (sop->mackeylen == auth_hash_hmac_sha2_512.keysize)
thash = &auth_hash_hmac_sha2_512;
- else
+ else {
+ mtx_unlock(&Giant);
return (EINVAL);
+ }
break;
case CRYPTO_RIPEMD160_HMAC:
thash = &auth_hash_hmac_ripemd_160_96;
@@ -215,6 +222,7 @@ cryptof_ioctl(
thash = &auth_hash_null;
break;
default:
+ mtx_unlock(&Giant);
return (EINVAL);
}
@@ -282,16 +290,20 @@ bail:
case CIOCFSESSION:
ses = *(u_int32_t *)data;
cse = csefind(fcr, ses);
- if (cse == NULL)
+ if (cse == NULL) {
+ mtx_unlock(&Giant);
return (EINVAL);
+ }
csedelete(fcr, cse);
error = csefree(cse);
break;
case CIOCCRYPT:
cop = (struct crypt_op *)data;
cse = csefind(fcr, cop->ses);
- if (cse == NULL)
+ if (cse == NULL) {
+ mtx_unlock(&Giant);
return (EINVAL);
+ }
error = cryptodev_op(cse, cop, active_cred, td);
break;
case CIOCKEY:
@@ -303,6 +315,7 @@ bail:
default:
error = EINVAL;
}
+ mtx_unlock(&Giant);
return (error);
}