[PATCH v6 12/25] security: replace strtok with reentrant version
Jie Hai
haijie1 at huawei.com
Fri Nov 22 12:04:44 CET 2024
Multiple threads calling the same function may cause condition
race issues, which often leads to abnormal behavior and can cause
more serious vulnerabilities such as abnormal termination, denial
of service, and compromised data integrity.
The strtok() is non-reentrant, it is better to replace it with a
reentrant version.
Fixes: 259ca6d1617f ("security: add telemetry endpoint for capabilities")
Signed-off-by: Jie Hai <haijie1 at huawei.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
---
lib/security/rte_security.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index e5c862f5f570..669888ef0807 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -11,6 +11,7 @@
#include <rte_cryptodev.h>
#include <dev_driver.h>
#include <rte_telemetry.h>
+#include <rte_os_shim.h>
#include "rte_security.h"
#include "rte_security_driver.h"
@@ -497,13 +498,14 @@ security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused, const char *
int dev_id, capa_id;
int crypto_caps_n;
char *end_param;
+ char *sp = NULL;
int rc;
if (!params || strlen(params) == 0 || !isdigit(*params))
return -EINVAL;
dev_id = strtoul(params, &end_param, 0);
- capa_param = strtok(end_param, ",");
+ capa_param = strtok_r(end_param, ",", &sp);
if (!capa_param || strlen(capa_param) == 0 || !isdigit(*capa_param))
return -EINVAL;
--
2.33.0
More information about the dev
mailing list