|WARNING| [v6,4/4] test/crypto: add asym test suite for AESNI_MB
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Tue Nov 10 13:41:24 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172799
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-10
# Review of DPDK Patch Series: crypto/ipsec_mb IPsecMB 3.0 Support
## Patch 1/4: crypto/ipsec_mb: add support for IPsecMB 3.0
### Errors
1. **Missing error checks on memory allocation (Error)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_gcm.c`
- Lines: 284-295 (session_configure function)
```c
switch (key_length) {
case 16:
sess->key_length = GCM_KEY_128;
imb_aes128_gcm_pre(key, &sess->gdata_key, mb_mgr);
break;
case 24:
sess->key_length = GCM_KEY_192;
imb_aes192_gcm_pre(key, &sess->gdata_key, mb_mgr);
break;
case 32:
sess->key_length = GCM_KEY_256;
imb_aes256_gcm_pre(key, &sess->gdata_key, mb_mgr);
break;
```
The `imb_aes*_gcm_pre()` wrapper functions call `state->gcm*_pre()` which are function pointers that could potentially fail, but no return value is checked. However, reviewing the library wrapper pattern, these are void-returning wrappers around library functions that also return void, so there is no error to check. This is acceptable.
**Correction: Not an error.**
### Warnings
1. **Inconsistent function pointer assignment pattern (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_gcm.c`
- Lines: 149-206
- The code assigns `IMB_MGR *mb_mgr` to each ops structure, then assigns function pointers. For library versions >= 3.0, the functions are direct IMB API calls; for < 3.0, they use the wrapper functions defined at the top of the file. This pattern is correct but the wrapper functions for < 3.0 could be more clearly documented.
- Suggestion: Add a comment explaining that the wrapper functions provide a unified interface across library versions.
2. **Large wrapper function block (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_gcm.c`
- Lines: 9-149
- The 140+ lines of wrapper functions are repetitive but necessary for backward compatibility. Consider documenting this block more clearly to explain why it exists and when it can be removed.
- Suggestion: Add a comment block explaining the version compatibility strategy.
3. **Documentation links updated but version mismatch (Warning)**
- Files: `doc/guides/cryptodevs/aesni_gcm.rst`, `doc/guides/cryptodevs/aesni_mb.rst`
- The documentation updates the supported version to v3.0 and provides new download links, but the links use different URL patterns:
- Old: `github.com/01org/intel-ipsec-mb/archive/v1.5.zip`
- New: `github.com/intel/intel-ipsec-mb/archive/refs/tags/v3.0.0.zip`
- The repository owner changed from `01org` to `intel`, which is correct, but ensure both URL patterns point to the same repository.
## Patch 2/4: crypto/ipsec_mb: add support for 256-NxA4/5/6 algorithms
### Errors
None identified.
### Warnings
1. **Capabilities structure initialization relies on version macros (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h`
- Lines: 1106-1330
- The large block of new capability structures for NxA4/5/6 algorithms is conditionally compiled based on `IMB_VERSION(3, 0, 0) <= IMB_VERSION_NUM`. This is correct, but the block is very large (227 lines) and repetitive.
- Suggestion: Consider documenting the structure of these capabilities or using helper macros to reduce repetition.
2. **Key size validation duplicated (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 685-705
- The validation `if (xform->cipher.key.length != 32)` appears multiple times for NxA algorithms. This is correct (all require 32-byte keys), but could be factored out.
## Patch 3/4: crypto/ipsec_mb: add support for ML-KEM and ML-DSA
### Errors
1. **Missing error cleanup on ML-KEM/ML-DSA context creation failure (Error)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 1055-1065, 1081-1091
```c
ret = imb_ml_kem_new(mb_mgr, sess->asym.ml_kem.alg, &sess->asym.ml_kem.ctx);
if (ret) {
IPSEC_MB_LOG(ERR, "Failed to create ML KEM session");
return ret;
}
```
If `imb_ml_kem_new()` or `imb_ml_dsa_new()` fails after allocating resources, the error path returns immediately without cleaning up any previously allocated memory in the session. However, this is in the session configure path where the session structure is being initialized for the first time. If configure fails, the caller is expected to discard the session without calling clear. The session clear function will be called only for successfully configured sessions. This pattern is acceptable given the API contract.
**Correction: Not an error in this context.**
2. **Potential uninitialized signature length (Error)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 2605-2610
```c
rc = imb_ml_dsa_sign(sess->asym.ml_dsa.ctx,
siggen->sign.data, &siggen->sign.length,
md, md_len, &sess->asym.ml_dsa.sign_params);
```
The `imb_ml_dsa_sign()` function takes `&siggen->sign.length` as an output parameter. If the buffer `siggen->sign.data` is too small, the library may write the required length to `siggen->sign.length` and return an error. However, if `siggen->sign.length` is not initialized before the call, this could be undefined behavior. The caller should set `siggen->sign.length` to the size of the provided buffer before calling.
- Check if the application is expected to initialize `siggen->sign.length` before calling the operation. If so, this code is correct. If not, it should be initialized here to the maximum signature size.
- Looking at the helper function `aesni_mb_ml_dsa_sig_sz()` defined earlier, it appears the code expects the application to have allocated a buffer of the correct size. This is typical for crypto APIs where buffer sizes are determined by the algorithm parameters.
**Correction: The API contract likely requires the application to provide a correctly sized buffer, so this is not an error in the PMD code itself.**
### Warnings
1. **Large switch statement with repetitive patterns (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 2548-2661
- The `aesni_mb_asym_process()` function has large switch statements for ML-KEM and ML-DSA operations. Each case follows a similar pattern: set parameters, call library function, check result. Consider using helper functions to reduce code duplication.
2. **Asymmetric session management mixed with symmetric (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 2848-2871
- The dequeue function now checks for asymmetric sessions and processes them inline while deferring symmetric operations to the job manager. This creates two different processing paths in the same function. The asymmetric operations are processed synchronously on dequeue, while symmetric operations go through the job queue.
- This is functionally correct but creates complexity. Consider documenting this dual-mode processing clearly, or separating the asymmetric and symmetric processing into different code paths.
3. **Session size calculation shared between sym and asym (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 3091-3093
```c
.asym_session_get_size = ipsec_mb_sym_session_get_size,
```
Asymmetric sessions reuse the symmetric session size function. This works because `struct aesni_mb_session` is a union containing both symmetric and asymmetric session data. However, if the asymmetric session structures (ML-KEM/ML-DSA contexts) require more space than symmetric sessions, this could lead to insufficient allocation.
- Verify that `sizeof(struct aesni_mb_session)` is large enough to hold the largest asymmetric session data (including the `IMB_ML_KEM` and `IMB_ML_DSA` context pointers).
- The structure at lines 1635-1676 in `pmd_aesni_mb_priv.h` shows that the asym member is a union containing pointers to contexts, not the contexts themselves. Since the contexts are allocated by the library, the session only needs to store pointers, so the size should be adequate. This is acceptable.
4. **Helper functions return size_t from switch on enum (Warning)**
- File: `drivers/crypto/ipsec_mb/pmd_aesni_mb.c`
- Lines: 2548-2589
- Functions like `aesni_mb_ml_kem_ek_sz()` use switch statements on enum values but don't have a default case and return 0 if the enum doesn't match. If a new ML-KEM algorithm is added to the library but not to the switch, the function silently returns 0, which could lead to buffer allocation failures later.
- Suggestion: Add a default case that logs an error and returns 0, or use `RTE_VERIFY()` to catch unexpected enum values during development.
## Patch 4/4: test/crypto: add asym test suite for AESNI_MB
### Errors
None identified.
### Warnings
None identified.
---
## General Observations
1. **Version compatibility strategy is clear (Info)**
- The patches use `#if IMB_VERSION(3, 0, 0) <= IMB_VERSION_NUM` consistently to provide conditional compilation for version-specific features. This is the correct approach and is well-applied throughout.
2. **Documentation updated appropriately (Info)**
- Release notes, RST documentation, and feature matrices are all updated consistently across the patches.
3. **No byte-aligned data feature removed (Info)**
- Patch 1 correctly removes the `RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA` feature flag and updates the features matrix to reflect this. The release notes document the removal with a clear explanation.
4. **New algorithms well-documented (Info)**
- The NxA4/5/6 algorithms and ML-KEM/ML-DSA support are properly documented in the cryptodev documentation and release notes.
---
Review-Result: WARNING
More information about the test-report
mailing list