Up to [cvs.NetBSD.org] / src / sys / opencrypto
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Sync with HEAD
crypto(4): Crank down max number of ops to something reasonable. Largest driver I found, qat(4), has at most 16384 sessions, so 64k oughta be enough for anyone. PR kern/60281: crypto(4): bugs in reference counting and test
Pull up following revision(s) (requested by riastradh in ticket #1278):
sys/opencrypto/cryptodev.c: revision 1.130
sys/opencrypto/cryptodev.c: revision 1.131
sys/opencrypto/cryptodev.c: revision 1.132
sys/opencrypto/cryptodev.c: revision 1.133
tests/crypto/opencrypto/Makefile: revision 1.6
sys/opencrypto/cryptosoft.c: revision 1.67
sys/opencrypto/ocryptodev.c: revision 1.19
tests/crypto/opencrypto/h_thread.c: revision 1.1
sys/rump/dev/lib/libopencrypto/OPENCRYPTO.ioconf: revision 1.2
tests/crypto/opencrypto/h_thread.c: revision 1.2
sys/rump/dev/lib/libopencrypto/opencrypto_component.c: revision 1.7
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.12
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.13
sys/opencrypto/cryptodev_internal.h: revision 1.5
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.14
sys/opencrypto/cryptodev.c: revision 1.129
distrib/sets/lists/debug/mi: revision 1.512
distrib/sets/lists/tests/mi: revision 1.1417
Add a threaded test to test for races in cryptodev.
new thread cryptodev test
crypto(4): Make test more reliable, and test more.
1. New thread to concurrently create and destroy sessions.
(There should really be multiple threads to concurrently compete
with each other to create and destroy sessions, but this is
already surfacing more crashes, as I expected.)
2. Handle EBUSY in CIOCFSESSION in case there is a concurrent
CIOCCRYPT, as we are trying to test.
3. Handle CIOCCRYPT failure if a concurrent CIOCFSESSION beat us to
it, as we are trying to test
4. Dump core if the threads get stuck for too long.
5. Provide stack traces from the test program or rump server if they
dump core.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Take reference _before_ releasing the lock.
Otherwise nothing ensures the object will still exist by the time we
try to take the reference.
Also guard against too many references, since this is only a 32-bit
reference count.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Fix missing membars on reference count release.
If two threads A and B both hold references, we need to ensure that
memory ops in thread A happen before memory free in thread B in:
thread A thread B notes
-------- -------- -----
memory ops
atomic_dec(&refcnt) goes from 2 to 1
atomic_dec(&refcnt) goes from 1 to 0
memory free
This requires a membar_release in thread A before the atomic_dec (or
atomic_dec with memory_order_release), and a membar_acquire in thread
B after the atomic_dec is found to have brought the reference count
down to zero (or atomic_dec wiht memory_order_acquire).
kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Disentangle initialization and attachment goo.
Lotta unnecessary boilerplate deleted here!
Disable module unloading: can't be done safely. Explain precisely
why it can't be done safely.
This also fixes annoying `crypto: unable to register devsw, error 17'
messages in rump dmesg by having exactly one path to devsw_attach.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Omit needless locking in fcrypt_dtor.
We must have exclusive access to the object for this function to work
at all, so if removing the locks appeared to cause issues, it would
necessarily happen only because there is a bug somewhere else.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Nix spurious mutex_exit; add missing bounds checks.
Consistently use `foo = kmem_alloc(n * sizeof(*foo), ...)' instead of
`sizeof(struct whatever_foo_is)'. Makes it easier for a reader to
notice a discrepancy this way.
Move CRYPTODEV_OPS_MAX to cryptodev_internal.h so it can be used by
the compat ocryptodev.c shims too. I think this is waaaaaaaaaaaaay
too high, by the way. For example, it looks like qat(4) puts a limit
of 16384 on the number of sessions. Other devices like hifn(4) look
like they're limited to numbers of sessions ranging from 2 to around
256.
PR kern/60281: crypto(4): bugs in reference counting and test
Pull up following revision(s) (requested by riastradh in ticket #330):
sys/opencrypto/cryptodev.c: revision 1.130
sys/opencrypto/cryptodev.c: revision 1.131
sys/opencrypto/cryptodev.c: revision 1.132
sys/opencrypto/cryptodev.c: revision 1.133
tests/crypto/opencrypto/Makefile: revision 1.6
sys/opencrypto/cryptosoft.c: revision 1.67
sys/opencrypto/ocryptodev.c: revision 1.19
tests/crypto/opencrypto/h_thread.c: revision 1.1
sys/rump/dev/lib/libopencrypto/OPENCRYPTO.ioconf: revision 1.2
tests/crypto/opencrypto/h_thread.c: revision 1.2
sys/rump/dev/lib/libopencrypto/opencrypto_component.c: revision 1.7
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.12
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.13
sys/opencrypto/cryptodev_internal.h: revision 1.5
tests/crypto/opencrypto/t_opencrypto.sh: revision 1.14
sys/opencrypto/cryptodev.c: revision 1.129
distrib/sets/lists/debug/mi: revision 1.512
distrib/sets/lists/tests/mi: revision 1.1417
Add a threaded test to test for races in cryptodev.
new thread cryptodev test
crypto(4): Make test more reliable, and test more.
1. New thread to concurrently create and destroy sessions.
(There should really be multiple threads to concurrently compete
with each other to create and destroy sessions, but this is
already surfacing more crashes, as I expected.)
2. Handle EBUSY in CIOCFSESSION in case there is a concurrent
CIOCCRYPT, as we are trying to test.
3. Handle CIOCCRYPT failure if a concurrent CIOCFSESSION beat us to
it, as we are trying to test
4. Dump core if the threads get stuck for too long.
5. Provide stack traces from the test program or rump server if they
dump core.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Take reference _before_ releasing the lock.
Otherwise nothing ensures the object will still exist by the time we
try to take the reference.
Also guard against too many references, since this is only a 32-bit
reference count.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Fix missing membars on reference count release.
If two threads A and B both hold references, we need to ensure that
memory ops in thread A happen before memory free in thread B in:
thread A thread B notes
-------- -------- -----
memory ops
atomic_dec(&refcnt) goes from 2 to 1
atomic_dec(&refcnt) goes from 1 to 0
memory free
This requires a membar_release in thread A before the atomic_dec (or
atomic_dec with memory_order_release), and a membar_acquire in thread
B after the atomic_dec is found to have brought the reference count
down to zero (or atomic_dec wiht memory_order_acquire).
kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Disentangle initialization and attachment goo.
Lotta unnecessary boilerplate deleted here!
Disable module unloading: can't be done safely. Explain precisely
why it can't be done safely.
This also fixes annoying `crypto: unable to register devsw, error 17'
messages in rump dmesg by having exactly one path to devsw_attach.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Omit needless locking in fcrypt_dtor.
We must have exclusive access to the object for this function to work
at all, so if removing the locks appeared to cause issues, it would
necessarily happen only because there is a bug somewhere else.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Nix spurious mutex_exit; add missing bounds checks.
Consistently use `foo = kmem_alloc(n * sizeof(*foo), ...)' instead of
`sizeof(struct whatever_foo_is)'. Makes it easier for a reader to
notice a discrepancy this way.
Move CRYPTODEV_OPS_MAX to cryptodev_internal.h so it can be used by
the compat ocryptodev.c shims too. I think this is waaaaaaaaaaaaay
too high, by the way. For example, it looks like qat(4) puts a limit
of 16384 on the number of sessions. Other devices like hifn(4) look
like they're limited to numbers of sessions ranging from 2 to around
256.
PR kern/60281: crypto(4): bugs in reference counting and test
crypto(4): Nix spurious mutex_exit; add missing bounds checks. Consistently use `foo = kmem_alloc(n * sizeof(*foo), ...)' instead of `sizeof(struct whatever_foo_is)'. Makes it easier for a reader to notice a discrepancy this way. Move CRYPTODEV_OPS_MAX to cryptodev_internal.h so it can be used by the compat ocryptodev.c shims too. I think this is waaaaaaaaaaaaay too high, by the way. For example, it looks like qat(4) puts a limit of 16384 on the number of sessions. Other devices like hifn(4) look like they're limited to numbers of sessions ranging from 2 to around 256. PR kern/60281: crypto(4): bugs in reference counting and test
Pull up following revision(s) (requested by christos in ticket #1262): sys/opencrypto/crypto.c: revision 1.132 sys/opencrypto/crypto.c: revision 1.133 sys/opencrypto/cryptosoft.h: revision 1.8 sys/opencrypto/xform.c: revision 1.32 sys/opencrypto/deflate.h: revision 1.10 sys/opencrypto/cryptodev.h: revision 1.52 sys/opencrypto/cryptosoft.c: revision 1.66 sys/opencrypto/cryptodev.h: revision 1.53 sys/opencrypto/ocryptodev.c: revision 1.18 sys/opencrypto/cryptodev_internal.h: revision 1.4 sys/opencrypto/aesxcbcmac.c: revision 1.4 sys/opencrypto/cryptodev.c: revision 1.127 sys/opencrypto/aesxcbcmac.h: revision 1.3 sys/opencrypto/cryptodev.c: revision 1.128 sys/opencrypto/cryptosoft_xform.c: revision 1.31 sys/opencrypto/deflate.c: revision 1.24 sys/opencrypto/deflate.c: revision 1.25 sys/opencrypto/xform.h: revision 1.22 sys/opencrypto/ocryptodev.h: revision 1.5 sys/opencrypto/ocryptodev.h: revision 1.6 u_intXX_t -> uintXX_t Fix: An integer wraparound bug that could cause a NULL pointer exception. Data sharing issues that could cause data corruption. Locking issues that could cause double freeing or using free memory. Issues discovered by nasm and coordinated by VulnCheck Thank you!
Pull up following revision(s) (requested by christos in ticket #262): sys/opencrypto/crypto.c: revision 1.132 sys/opencrypto/crypto.c: revision 1.133 sys/opencrypto/cryptosoft.h: revision 1.8 sys/opencrypto/xform.c: revision 1.32 sys/opencrypto/deflate.h: revision 1.10 sys/opencrypto/cryptodev.h: revision 1.52 sys/opencrypto/cryptosoft.c: revision 1.66 sys/opencrypto/cryptodev.h: revision 1.53 sys/opencrypto/ocryptodev.c: revision 1.18 sys/opencrypto/cryptodev_internal.h: revision 1.4 sys/opencrypto/aesxcbcmac.c: revision 1.4 sys/opencrypto/cryptodev.c: revision 1.127 sys/opencrypto/aesxcbcmac.h: revision 1.3 sys/opencrypto/cryptodev.c: revision 1.128 sys/opencrypto/cryptosoft_xform.c: revision 1.31 sys/opencrypto/deflate.c: revision 1.24 sys/opencrypto/deflate.c: revision 1.25 sys/opencrypto/xform.h: revision 1.22 sys/opencrypto/ocryptodev.h: revision 1.5 sys/opencrypto/ocryptodev.h: revision 1.6 u_intXX_t -> uintXX_t Fix: An integer wraparound bug that could cause a NULL pointer exception. Data sharing issues that could cause data corruption. Locking issues that could cause double freeing or using free memory. Issues discovered by nasm and coordinated by VulnCheck Thank you!
Fix: An integer wraparound bug that could cause a NULL pointer exception. Data sharing issues that could cause data corruption. Locking issues that could cause double freeing or using free memory. Issues discovered by nasm and coordinated by VulnCheck Thank you!
update from HEAD
Sync with HEAD
rename crypto_mtx to cryptodev_mtx It is used by cryptodev.c and ocryptodev.c only.
Sync with HEAD
separate crypto_drv_mtx from crypto_mtx. crypto_mtx is used only for cryptodev.c and ocryptodev.c now.
Sync with HEAD.
sync with head
Sync with HEAD
file cryptodev_internal.h was added on branch jruoho-x86intr on 2011-06-06 09:10:03 +0000
file cryptodev_internal.h was added on branch rmind-uvmplock on 2011-03-05 20:56:05 +0000
file cryptodev_internal.h was added on branch bouyer-quota2 on 2011-03-05 15:10:48 +0000
make the compatibility code conditional on COMPAT_50