diff options
author | phk <phk@FreeBSD.org> | 2004-11-17 09:09:55 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-11-17 09:09:55 +0000 |
commit | d6a49a1565bec352a92f40326206665b53769de2 (patch) | |
tree | 3e96ca6c2f3203ce32ec61d3746561cf0c4bd761 /sys/opencrypto/cryptodev.c | |
parent | 313ccfcf9e23e29fc79adcefe9b9e1b52f7643ff (diff) | |
download | FreeBSD-src-d6a49a1565bec352a92f40326206665b53769de2.zip FreeBSD-src-d6a49a1565bec352a92f40326206665b53769de2.tar.gz |
Push Giant down through ioctl.
Don't grab Giant in the upper syscall/wrapper code
NET_LOCK_GIANT in the socket code (sockets/fifos).
mtx_lock(&Giant) in the vnode code.
mtx_lock(&Giant) in the opencrypto code. (This may actually not be
needed, but better safe than sorry).
Devfs grabs Giant if the driver is marked as needing Giant.
Diffstat (limited to 'sys/opencrypto/cryptodev.c')
-rw-r--r-- | sys/opencrypto/cryptodev.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 9b0da7c..b9d26a9 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); } |