summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2014-10-22 05:37:54 +0000
committerdlg <dlg@openbsd.org>2014-10-22 05:37:54 +0000
commit4312a6b15e9895f4023eab7b08f92deac364773c (patch)
treea578971808f47c8085c9c4eb0d4eef0605586423
parentAvoid writing in second person in malloc.3 (diff)
downloadwireguard-openbsd-4312a6b15e9895f4023eab7b08f92deac364773c.tar.xz
wireguard-openbsd-4312a6b15e9895f4023eab7b08f92deac364773c.zip
make the crypto taskq protect things at IPL_VM instead of IPL_HIGH.
everything else in crypto.c uses splvm/IPL_VM. it seems this IPL_HIGH came about because the hand rolled task list and thread that crypto used to use was converted to workqs, which unconditionally used IPL_HIGH internally. when it was converted from workqs to tasks it blindly ported the protection workqs gave. tested by many via tech@ and snapshots ok kettenis@
-rw-r--r--sys/crypto/crypto.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index ee8bd8dfe41..e56c04b65a8 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.68 2014/10/20 00:40:33 dlg Exp $ */
+/* $OpenBSD: crypto.c,v 1.69 2014/10/22 05:37:54 dlg Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -453,20 +453,16 @@ void
crypto_freereq(struct cryptop *crp)
{
struct cryptodesc *crd;
- int s;
if (crp == NULL)
return;
- s = splvm();
-
while ((crd = crp->crp_desc) != NULL) {
crp->crp_desc = crd->crd_next;
pool_put(&cryptodesc_pool, crd);
}
pool_put(&cryptop_pool, crp);
- splx(s);
}
/*
@@ -477,20 +473,14 @@ crypto_getreq(int num)
{
struct cryptodesc *crd;
struct cryptop *crp;
- int s;
- s = splvm();
-
crp = pool_get(&cryptop_pool, PR_NOWAIT | PR_ZERO);
- if (crp == NULL) {
- splx(s);
+ if (crp == NULL)
return NULL;
- }
while (num--) {
crd = pool_get(&cryptodesc_pool, PR_NOWAIT | PR_ZERO);
if (crd == NULL) {
- splx(s);
crypto_freereq(crp);
return NULL;
}
@@ -499,19 +489,20 @@ crypto_getreq(int num)
crp->crp_desc = crd;
}
- splx(s);
return crp;
}
void
crypto_init(void)
{
- crypto_taskq = taskq_create("crypto", 1, IPL_HIGH);
+ crypto_taskq = taskq_create("crypto", 1, IPL_VM);
pool_init(&cryptop_pool, sizeof(struct cryptop), 0, 0,
0, "cryptop", NULL);
+ pool_setipl(&cryptop_pool, IPL_VM);
pool_init(&cryptodesc_pool, sizeof(struct cryptodesc), 0, 0,
0, "cryptodesc", NULL);
+ pool_setipl(&cryptodesc_pool, IPL_VM);
}
/*