Skip to content

Commit 5081f55

Browse files
committed
F-12216: document that the async poll callback runs under the queue lock
The event queue poll has always held queue->lock across the device poll, for QAT, Nitrox and the software backend. The crypto callback poll follows the same model. Holding the lock is intended: it serializes the poll callbacks of one queue. State the rule a handler has to follow instead of changing the locking.
1 parent a4db82e commit 5081f55

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎doc/dox_comments/header_files-ja/cryptocb.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
TPMベースの暗号コールバックの例については、wolfTPM src/tpm2_wrap.cのwolfTPM2_CryptoDevCb関数を参照してください。
99
10+
WOLFSSL_ASYNC_CRYPTとWOLF_CRYPTO_CB_ASYNC_POLLが定義されている場合、保留中の操作を完了させるために、wolfSSL_AsyncPollおよびwolfSSL_CTX_AsyncPollからWC_ALGO_TYPE_ASYNC_POLLでコールバックが呼び出されます。この呼び出しの間、イベントキューのロックは保持されています。ハンドラは、同じWOLFSSL_CTXに対してポーリングやTLS操作を行ってはならず、同じWOLF_EVENT_QUEUEを他のいかなる方法でも使用してはなりません。デッドロックが発生します。
11+
1012
\return CRYPTOCB_UNAVAILABLE ソフトウェア暗号の使用にフォールバックする場合
1113
\return 0 成功時
1214
\return 負の値 失敗時

‎doc/dox_comments/header_files/cryptocb.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
devIds the handler already registered stay registered and are the
2626
caller's to clean up.
2727
28+
With WOLFSSL_ASYNC_CRYPT and WOLF_CRYPTO_CB_ASYNC_POLL defined, the
29+
callback is invoked with WC_ALGO_TYPE_ASYNC_POLL from
30+
wolfSSL_AsyncPoll and wolfSSL_CTX_AsyncPoll to complete a pending
31+
operation. The event queue lock is held for this call. The handler
32+
must not poll or run TLS operations on the same WOLFSSL_CTX, or use
33+
the same WOLF_EVENT_QUEUE in any other way: that deadlocks.
34+
2835
\return CRYPTOCB_UNAVAILABLE to fallback to using software crypto
2936
\return 0 for success
3037
\return ALREADY_E if devId is already registered. A devId must be

‎wolfssl/wolfcrypt/cryptocb.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,8 @@ WOLFSSL_API void wc_CryptoCb_SetDeviceFindCb(CryptoDevCallbackFind cb);
12231223
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WOLF_CRYPTO_CB_ASYNC_POLL)
12241224
/* Poll completion for bulk cipher ops: on WC_PENDING_E the callback saves
12251225
* the output pointers; wolfSSL_AsyncPoll() re-enters it with
1226-
* WC_ALGO_TYPE_ASYNC_POLL to finish the job and fill the buffer. */
1226+
* WC_ALGO_TYPE_ASYNC_POLL to finish the job and fill the buffer. The event
1227+
* queue lock is held for that call, so the callback must not use the queue. */
12271228
WOLFSSL_LOCAL int wc_CryptoCb_Poll(int devId);
12281229
#endif
12291230

0 commit comments

Comments
 (0)