|WARNING| [v2, 2/2] crypto/openssl: load default provider first legacy optional
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu Nov 26 10:09:30 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/173201
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-26
**Patch 2/2: crypto/openssl: load default provider first legacy optional**
**Error: the failure path unloads a provider this call never loaded.**
```c
+ if (ossl_providers_load() < 0) {
+ ossl_providers_unload();
+ return -ENOTSUP;
+ }
```
`ossl_providers_load()` fails only when the default provider fails to load. That happens before `legacy` is touched, so nothing is held at this point. But `ossl_providers_unload()` still calls `OSSL_PROVIDER_unload(legacy)` on the global `legacy` pointer.
With more than one openssl vdev, `legacy` still holds the reference taken by an earlier, successfully created device. This failure drops that device's reference. When that device is later removed, `cryptodev_openssl_remove()` unloads `legacy` again: a double unload and use-after-free of the provider.
The failed load has also already overwritten the global `deflt` with NULL, so the earlier device's default-provider reference leaks.
Fix: return directly on load failure, without calling `ossl_providers_unload()`. Better still, have `ossl_providers_load()` use locals and only commit them to the globals on success.
**Error: `init_error` double-unloads providers whenever the device was created.**
```c
cryptodev_openssl_remove(vdev);
+ ossl_providers_unload();
```
`cryptodev_openssl_remove()` already unloads providers when it finds the device:
```c
if (cryptodev == NULL)
return -ENODEV;
- ossl_legacy_provider_unload();
+ ossl_providers_unload();
```
For any `goto init_error` taken after `rte_cryptodev_pmd_create()` succeeds, `remove()` finds the device and unloads both providers. `init_error` then calls `ossl_providers_unload()` a second time on the same `legacy`/`deflt` pointers. Each extra unload drops a provider reference that was never taken.
The extra unload is only correct on the `dev == NULL` path, where `remove()` returns `-ENODEV`. Fix by doing one of the following:
- Unload explicitly only in the `dev == NULL` branch.
- Move the provider unload out of `cryptodev_openssl_remove()` into a path executed exactly once.
**Info (pre-existing, not introduced by this patch): providers are tracked in shared globals but loaded per device.**
```c
OSSL_PROVIDER *legacy;
OSSL_PROVIDER *deflt;
```
Each `cryptodev_openssl_create()` overwrites these globals, and each `cryptodev_openssl_remove()` unloads them. With multiple openssl vdevs, earlier references are leaked, and removing one device drops providers that the others still depend on. Consider reference-counting the load per driver rather than per device.
**Info: the capability array is rebuilt from scratch on every create.**
`openssl_pmd_caps_init()` rebuilds the global `openssl_pmd_caps_active[]` and calls `EVP_CIPHER_fetch()` once per DES entry on each device create. A single fetch, cached in a local `bool`, would be cheaper.
Review-Result: ERROR
More information about the test-report
mailing list