NetBSD/sys/opencrypto
knakahara 7c4d1f974f fix race among crypto_done(), cryptoret(), and {cryptodev_op(), cryptodev_key()}.
crypto_op() waited to be set CRYPTO_F_DONE with crp->crp_cv.
However, there is context switch chances between being set CRYPTO_F_DONE in
crypto_done() and done cv_signal(crp->crp_cv) in cryptodev_cb(), that is,
cryptodev_op() thread can run to cv_destroy(crp->crp_cv) before cryptoret()
thread is waken up. As a result, cryptodev_cb() can call invalid(destroyed)
cv_signal(crp->crp_cv).

Furthermore, below two implementations cause other races.
    - waiting CRYPTO_F_DONE with crp->crp_cv
    - context witch chances between set CRYPTO_F_DONE and cv_signal(crp->crp_cv)

So, use other flag(CRYPTO_F_DQRETQ) for cryptodev_op() and cryptodev_key(),
and then call cv_signal(crp->crp_cv) immediately after set CRYPTO_F_DQRETQ.

Tested concurrent over 20 processes with software and hardware drivers.
2017-04-07 12:15:51 +00:00
..
aesxcbcmac.c From Alexander Nasonov: 2016-09-26 14:50:54 +00:00
aesxcbcmac.h
criov.c
crypto.c fix build failure ALL 2017-04-06 09:39:12 +00:00
cryptodev_internal.h
cryptodev.c fix race among crypto_done(), cryptoret(), and {cryptodev_op(), cryptodev_key()}. 2017-04-07 12:15:51 +00:00
cryptodev.h fix race among crypto_done(), cryptoret(), and {cryptodev_op(), cryptodev_key()}. 2017-04-07 12:15:51 +00:00
cryptosoft_xform.c
cryptosoft.c
cryptosoft.h
deflate.c
deflate.h
files.opencrypto
gmac.c
gmac.h
Makefile
ocryptodev.c
ocryptodev.h More on PR 41200: headers that declare ioctls should include sys/ioccom.h. 2015-09-06 06:00:59 +00:00
xform.c
xform.h