|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 14:41:08 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

# DPDK Patch Review

## Patch 1/4: crypto/ipsec_mb: add support for IPsecMB 3.0

### Errors

**Error 1: Missing error checks on function calls**

In `pmd_aesni_gcm.c`, lines 285-296, the `imb_aesXXX_gcm_pre()` functions are called without checking for errors. These functions can fail if key expansion fails, and the error must be propagated:

```c
/* BAD - no error check */
imb_aes128_gcm_pre(key, &sess->gdata_key, mb_mgr);

/* GOOD - check return value */
int ret = imb_aes128_gcm_pre(key, &sess->gdata_key, mb_mgr);
if (ret != 0) {
    IPSEC_MB_LOG(ERR, "Key pre-processing failed");
    return -EINVAL;
}
```

However, I cannot verify from the patch alone whether these functions return void or int in IPsecMB 3.0. If they return void, this finding is invalid. Without tool access to read the library headers, I cannot determine this definitively, so I will not file this as an Error.

**Error 2: Potential resource leak in wrapper functions**

The wrapper functions in `pmd_aesni_gcm.c` (lines 11-145) allocate or initialize context data structures but do not have clear cleanup paths. If these functions fail partway through (for example, if `state->gcmXXX_init()` fails), there is no indication that previously allocated resources are freed. This pattern appears in all the wrapper functions.

However, without access to the IPsecMB 3.0 library source to verify whether these function pointers can fail and what cleanup they require, I cannot definitively state this is a leak. The patch shows only the function signatures changing; the implementation is in the external library. This would require reading the library documentation or source to verify, which is outside the scope of diff-only review.

### Warnings

**Warning 1: Documentation refers to unreleased version**

In `doc/guides/cryptodevs/aesni_gcm.rst`, line 43, and `doc/guides/cryptodevs/aesni_mb.rst`, line 116, the documentation states:

```rst
The latest version of the library supported by this PMD is v3.0, which
can be downloaded from `<https://github.com/intel/intel-ipsec-mb/archive/refs/tags/v3.0.0.zip>`_.
```

The URL points to a tag that may not exist yet (v3.0.0). The documentation should be updated to point to an actual release when it becomes available, or note that this is a pre-release version. As written, users following this link may encounter a 404 error.

**Warning 2: Release notes formatting inconsistency**

In `doc/guides/rel_notes/release_26_11.rst`, line 27:

```rst
* **Updated AESNI_MB crypto driver.**

  * Added support for version 3.0 of IPsec MB Library.
```

The sub-bullet indentation is correct, but the release notes should state explicitly what changed for users (features removed, new APIs, behavioral changes), not just the library version bump. The Note section later (line 88) mentions ZUC-256 removal and non-byte-aligned removal, but this is separated from the main feature entry.

**Warning 3: Missing deprecation notices**

The patch removes support for ZUC-256 and non-byte-aligned data (as documented in the "Note" section added at line 86). According to DPDK contribution guidelines, such removals should have been preceded by deprecation notices in a prior release. The patch does not indicate whether such notices were present. If they were not, this is a policy violation.

**Warning 4: Overly defensive macro checks**

Throughout `pmd_aesni_mb.c`, the patch wraps every reference to removed enums in `#if IMB_VERSION(3, 0, 0) > IMB_VERSION_NUM`. This is correct for backward compatibility, but it adds significant complexity. The code now has two parallel paths for nearly every bit-length calculation. An alternative would be to define compatibility macros at the top of the file to map old names to new names, reducing the number of conditional blocks.

This is not an error, but it makes the code harder to maintain. Consider consolidating the version checks into a smaller number of compatibility definitions.

### Info

**Info 1: Large number of mechanical substitutions**

The patch performs many mechanical substitutions of enum names (e.g., `IMB_AUTH_ZUC_EIA3_BITLEN` - `IMB_AUTH_ZUC_EIA3`). These are correct and necessary for IPsecMB 3.0, but the volume of changes increases the risk of a missed substitution. Recommend verifying with grep that no old enum names remain in code not guarded by version checks.

**Info 2: Wrapper function pattern**

The wrapper functions introduced in `pmd_aesni_gcm.c` (lines 9-145) are a clever compatibility layer for IPsecMB < 3.0, where the function pointers were stored in `IMB_MGR` and are now direct API calls. This pattern is clean and maintains backward compatibility. No issues found in the implementation.

---

## Patch 2/4: crypto/ipsec_mb: add support for 256-NxA4/5/6 algorithms

### Errors

None identified. The patch adds new algorithm support gated on `IMB_VERSION(3, 0, 0)`, which is the correct approach.

### Warnings

**Warning 1: Release notes formatting**

In `doc/guides/rel_notes/release_26_11.rst`, line 30:

```rst
  * Added support for the following wireless algorithms:
       - NEA4, NIA4, NCA4: Snow 5G confidentiality, integrity and AEAD modes.
       - NEA5, NIA5, NCA5: AES 256 confidentiality, integrity and AEAD modes.
       - NEA6, NIA6, NCA6: ZUC 256 confidentiality, integrity and AEAD modes.
```

The indentation uses spaces instead of the standard RST bullet list format. Should be:

```rst
  * Added support for the following wireless algorithms:

    - NEA4, NIA4, NCA4: Snow 5G confidentiality, integrity and AEAD modes.
    - NEA5, NIA5, NCA5: AES 256 confidentiality, integrity and AEAD modes.
    - NEA6, NIA6, NCA6: ZUC 256 confidentiality, integrity and AEAD modes.
```

Note the blank line after the introductory sentence and the consistent `- ` bullet markers.

**Warning 2: Missing capability size limits**

In `pmd_aesni_mb_priv.h`, the new algorithm capabilities (lines 1106-1330) specify key sizes, IV sizes, and digest sizes, but do not specify message length limits. For example, NIA4/NIA5/NIA6 auth algorithms and NEA4/NEA5/NEA6 cipher algorithms should have a `data_size` field indicating maximum message length supported by the hardware or library. Without this, applications cannot determine safe operating limits.

If the library imposes no limit (or the limit is > `UINT32_MAX`), this should be documented in the capability structure.

### Info

**Info 1: Consistent pattern with symmetric algorithms**

The implementation follows the same pattern as existing symmetric algorithms (session setup, template job configuration, parameter passing). No deviations or risks identified.

---

## Patch 3/4: crypto/ipsec_mb: add support for ML-KEM and ML-DSA

### Errors

**Error 1: Missing error check in session configure**

In `pmd_aesni_mb.c`, line 1055:

```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;
}
```

The code checks `if (ret)` but does not verify that `sess->asym.ml_kem.ctx` is non-NULL. If `imb_ml_kem_new()` returns 0 but sets `ctx` to NULL (indicating out-of-memory or other internal failure), the subsequent operations will dereference a NULL pointer. Add:

```c
if (ret || sess->asym.ml_kem.ctx == NULL) {
    IPSEC_MB_LOG(ERR, "Failed to create ML KEM session");
    return ret ? ret : -ENOMEM;
}
```

The same issue exists for `imb_ml_dsa_new()` at line 1082.

**Error 2: Resource leak on partial session setup failure**

In `aesni_mb_asym_session_configure()`, if `imb_ml_kem_new()` succeeds but a later validation fails (e.g., unsupported type in the switch statement at line 1050), the function returns `-ENOTSUP` without calling `imb_ml_kem_free()`. This leaks the ML-KEM context.

Add cleanup on all error paths:

```c
case RTE_CRYPTO_ASYM_XFORM_ML_KEM:
{
    /* ... setup code ... */
    ret = imb_ml_kem_new(mb_mgr, sess->asym.ml_kem.alg, &sess->asym.ml_kem.ctx);
    if (ret || sess->asym.ml_kem.ctx == NULL) {
        IPSEC_MB_LOG(ERR, "Failed to create ML KEM session");
        return ret ? ret : -ENOMEM;
    }
    IMB_ML_KEM_KEYGEN_PARAMS_INIT(&sess->asym.ml_kem.keygen_params);
    IMB_ML_KEM_ENCAP_PARAMS_INIT(&sess->asym.ml_kem.encap_params);
    break;  /* SUCCESS - context is now managed by session */
}

/* ... */

default:
    ret = -ENOTSUP;
    IPSEC_MB_LOG(ERR, "Unsupported algorithm");
    /* NO cleanup needed - context not yet allocated */
    return ret;
```

However, the default case at line 1091 is reached only if the switch falls through without matching any case. At that point, no `imb_ml_*_new()` has been called, so there is nothing to free. The actual leak would occur if the `imb_ml_kem_new()` call succeeds but the type check inside the ML_KEM case fails--but there is no such check. The type validation happens at line 1030 and returns immediately on failure, before `imb_ml_kem_new()` is called. So there is no leak.

Discard this finding--the code is correct.

**Error 3: Use of unvalidated buffer lengths**

In `aesni_mb_asym_process()`, line 1130:

```c
memcpy(seed_d_z,      keygen->d.data, 32);
memcpy(&seed_d_z[32], keygen->z.data, 32);
```

The code assumes `keygen->d.length` and `keygen->z.length` are both 32, but does not verify this. If the application passes a shorter buffer, this reads beyond the end of the buffer. Add:

```c
if (keygen->d.length != 32 || keygen->z.length != 32) {
    op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
    return;
}
memcpy(seed_d_z,      keygen->d.data, 32);
memcpy(&seed_d_z[32], keygen->z.data, 32);
```

The same issue exists for other operations that assume fixed buffer sizes (e.g., `keygen->ek.length` at line 1136, `encap->message.length` at line 1147).

### Warnings

**Warning 1: Asymmetric crypto session size reuses symmetric size**

In `pmd_aesni_mb.c`, line 2294:

```c
.asym_session_get_size = ipsec_mb_sym_session_get_size,
```

The asymmetric session ops reuse the symmetric session size getter. This works only because `struct aesni_mb_session` is a union-like structure that can hold either symmetric or asymmetric session data. However, if the asymmetric session data grows larger than the symmetric session data in a future version, this will cause silent truncation and memory corruption.

Recommend adding a static assertion or runtime check to ensure the asymmetric session data fits within the allocated size, or implement a separate size getter for asymmetric sessions.

**Warning 2: Dequeue loop processes asymmetric ops synchronously**

In `pmd_aesni_mb.c`, line 2849:

```c
if (tmp_dq[i]->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
    aesni_mb_asym_process(tmp_dq[i]);
    ops[processed_jobs++] = tmp_dq[i];
}
```

Asymmetric crypto operations are processed synchronously inside the dequeue loop, blocking the dequeue thread until the operation completes. For ML-KEM and ML-DSA, which can take milliseconds for key generation, this introduces significant latency.

This is acceptable for a first implementation, but the documentation should note that asymmetric operations are synchronous and block the queue pair. Consider adding this to the PMD guide.

**Warning 3: Missing release notes update for asymmetric support**

The release notes in `doc/guides/rel_notes/release_26_11.rst` add ML-KEM and ML-DSA to the feature list, but do not mention that this is the first asymmetric crypto support in the AESNI_MB PMD. Users upgrading from a previous version may not realize that the PMD now supports asymmetric operations. Add a note stating that asymmetric crypto is now supported.

### Info

**Info 1: Clean conditional compilation for asym support**

The patch gates all asymmetric crypto code on `IMB_VERSION(3, 0, 0)`, which is correct since older library versions do not support ML-KEM or ML-DSA. The fallback behavior (asym ops not supported) is implicit and handled gracefully.

---

## Patch 4/4: test/crypto: add asym test suite for AESNI_MB

### Errors

None identified. The patch adds a single test registration; the test suite itself is pre-existing.

### Warnings

None identified.

### Info

**Info 1: Test suite registration**

The patch enables the existing asymmetric test suite for the AESNI_MB PMD. This is the correct approach--no need to duplicate test infrastructure.

---

## Summary

This patch series adds support for IPsecMB 3.0 to the DPDK AESNI_MB PMD. The changes are extensive but well-structured, with clear conditional compilation for backward compatibility.

**Critical issues:**
- Buffer length validation missing in ML-KEM/ML-DSA asymmetric operations (Error 3 in Patch 3)
- NULL pointer check missing after `imb_ml_kem_new()` and `imb_ml_dsa_new()` (Error 1 in Patch 3)

**Non-critical issues:**
- Documentation URLs may be broken (Warning 1 in Patch 1)
- Missing deprecation notices for removed features (Warning 3 in Patch 1)
- Release notes formatting (Warnings in Patches 1, 2)
- Asymmetric session size reuse may cause issues in future (Warning 1 in Patch 3)

Review-Result: ERROR


More information about the test-report mailing list