[v5,44/52] net/sfc: replace strerror with reentrant version

Message ID 20241104111037.3632161-45-huangdengdui@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series replace strerror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

huangdengdui Nov. 4, 2024, 11:10 a.m. UTC
The function strerror() is insecure in a multi-thread environment.
This patch uses strerror_r() to replace it.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
---
 drivers/net/sfc/sfc_flow.c        |   5 +-
 drivers/net/sfc/sfc_flow_tunnel.c |   6 +-
 drivers/net/sfc/sfc_mae.c         | 152 +++++++++++++++++++++++-------
 3 files changed, 126 insertions(+), 37 deletions(-)
  

Patch

diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 1006243539..52c5800b10 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -1321,6 +1321,7 @@  sfc_flow_parse_pattern(struct sfc_adapter *sa,
 	unsigned int prev_layer = SFC_FLOW_ITEM_ANY_LAYER;
 	boolean_t is_ifrm = B_FALSE;
 	const struct sfc_flow_item *item;
+	char errmsg[RTE_STRERR_BUFSIZE];
 
 	if (pattern == NULL) {
 		rte_flow_error_set(error, EINVAL,
@@ -1396,8 +1397,10 @@  sfc_flow_parse_pattern(struct sfc_adapter *sa,
 
 		rc = item->parse(pattern, parse_ctx, error);
 		if (rc != 0) {
+			if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc);
 			sfc_err(sa, "failed to parse item %s: %s",
-				item->name, strerror(-rc));
+				item->name, errmsg);
 			return rc;
 		}
 
diff --git a/drivers/net/sfc/sfc_flow_tunnel.c b/drivers/net/sfc/sfc_flow_tunnel.c
index 889fee569a..9bd4d10f17 100644
--- a/drivers/net/sfc/sfc_flow_tunnel.c
+++ b/drivers/net/sfc/sfc_flow_tunnel.c
@@ -60,6 +60,7 @@  sfc_ft_tunnel_rule_detect(struct sfc_adapter *sa,
 {
 	const struct rte_flow_action_mark *action_mark = NULL;
 	const struct rte_flow_action_jump *action_jump = NULL;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	struct sfc_ft_ctx *ft_ctx;
 	uint32_t flow_mark = 0;
 	int rc = 0;
@@ -118,9 +119,10 @@  sfc_ft_tunnel_rule_detect(struct sfc_adapter *sa,
 		sfc_dbg(sa, "FT: TUNNEL: detected");
 
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			/* The loop above might have spotted wrong actions. */
-			sfc_err(sa, "FT: TUNNEL: invalid actions: %s",
-				strerror(rc));
+			sfc_err(sa, "FT: TUNNEL: invalid actions: %s", errmsg);
 			goto fail;
 		}
 
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index b0e8b02b41..dfa9b5d9a1 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -410,6 +410,7 @@  sfc_mae_outer_rule_enable(struct sfc_adapter *sa,
 			  efx_mae_match_spec_t *match_spec_action)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (rule == NULL)
@@ -427,8 +428,10 @@  sfc_mae_outer_rule_enable(struct sfc_adapter *sa,
 					       rule->encap_type,
 					       &fw_rsrc->rule_id);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable outer_rule=%p: %s",
-				rule, strerror(rc));
+				rule, errmsg);
 			return rc;
 		}
 	}
@@ -445,7 +448,9 @@  sfc_mae_outer_rule_enable(struct sfc_adapter *sa,
 			fw_rsrc->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
 		}
 
-		sfc_err(sa, "can't match on outer rule ID: %s", strerror(rc));
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
+		sfc_err(sa, "can't match on outer rule ID: %s", errmsg);
 
 		return rc;
 	}
@@ -468,6 +473,7 @@  sfc_mae_outer_rule_disable(struct sfc_adapter *sa,
 {
 	efx_mae_rule_id_t invalid_rule_id = { .id = EFX_MAE_RSRC_ID_INVALID };
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (rule == NULL)
@@ -483,8 +489,10 @@  sfc_mae_outer_rule_disable(struct sfc_adapter *sa,
 	rc = efx_mae_match_spec_outer_rule_id_set(match_spec_action,
 						  &invalid_rule_id);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "cannot restore match on invalid outer rule ID: %s",
-			strerror(rc));
+			errmsg);
 		return;
 	}
 
@@ -502,8 +510,10 @@  sfc_mae_outer_rule_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled outer_rule=%p with OR_ID=0x%08x",
 				rule, fw_rsrc->rule_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable outer_rule=%p with OR_ID=0x%08x: %s",
-				rule, fw_rsrc->rule_id.id, strerror(rc));
+				rule, fw_rsrc->rule_id.id, errmsg);
 		}
 		fw_rsrc->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
 	}
@@ -600,6 +610,7 @@  sfc_mae_mac_addr_enable(struct sfc_adapter *sa,
 			efx_mae_actions_t *aset_spec)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc = 0;
 
 	if (mac_addr == NULL)
@@ -615,8 +626,10 @@  sfc_mae_mac_addr_enable(struct sfc_adapter *sa,
 		rc = efx_mae_mac_addr_alloc(sa->nic, mac_addr->addr_bytes,
 					    &fw_rsrc->mac_id);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable mac_addr=%p: %s",
-				mac_addr, strerror(rc));
+				mac_addr, errmsg);
 			return rc;
 		}
 	}
@@ -641,8 +654,9 @@  sfc_mae_mac_addr_enable(struct sfc_adapter *sa,
 			fw_rsrc->mac_id.id = EFX_MAE_RSRC_ID_INVALID;
 		}
 
-		sfc_err(sa, "cannot fill in MAC address entry ID: %s",
-			strerror(rc));
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
+		sfc_err(sa, "cannot fill in MAC address entry ID: %s", errmsg);
 
 		return rc;
 	}
@@ -662,6 +676,7 @@  sfc_mae_mac_addr_disable(struct sfc_adapter *sa,
 			 struct sfc_mae_mac_addr *mac_addr)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (mac_addr == NULL)
@@ -684,8 +699,10 @@  sfc_mae_mac_addr_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled mac_addr=%p with MAC_ID=0x%08x",
 				mac_addr, fw_rsrc->mac_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable mac_addr=%p with MAC_ID=0x%08x: %s",
-				mac_addr, fw_rsrc->mac_id.id, strerror(rc));
+				mac_addr, fw_rsrc->mac_id.id, errmsg);
 		}
 		fw_rsrc->mac_id.id = EFX_MAE_RSRC_ID_INVALID;
 	}
@@ -795,6 +812,7 @@  sfc_mae_encap_header_update(struct sfc_adapter *sa,
 {
 	const struct sfc_mae_bounce_eh *bounce_eh = &sa->mae.bounce_eh;
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	uint8_t *buf;
 	int ret;
 
@@ -817,8 +835,10 @@  sfc_mae_encap_header_update(struct sfc_adapter *sa,
 						  encap_header->type, buf,
 						  bounce_eh->size);
 		if (ret != 0) {
+			if (strerror_r(ret, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ret);
 			sfc_err(sa, "failed to update encap_header=%p: %s",
-				encap_header, strerror(ret));
+				encap_header, errmsg);
 			rte_free(buf);
 			return ret;
 		}
@@ -839,6 +859,7 @@  sfc_mae_encap_header_enable(struct sfc_adapter *sa,
 			    efx_mae_actions_t *action_set_spec)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (encap_header == NULL)
@@ -858,8 +879,10 @@  sfc_mae_encap_header_enable(struct sfc_adapter *sa,
 						encap_header->size,
 						&fw_rsrc->eh_id);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable encap_header=%p: %s",
-				encap_header, strerror(rc));
+				encap_header, errmsg);
 			return rc;
 		}
 	}
@@ -873,7 +896,9 @@  sfc_mae_encap_header_enable(struct sfc_adapter *sa,
 			fw_rsrc->eh_id.id = EFX_MAE_RSRC_ID_INVALID;
 		}
 
-		sfc_err(sa, "can't fill in encap. header ID: %s", strerror(rc));
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
+		sfc_err(sa, "can't fill in encap. header ID: %s", errmsg);
 
 		return rc;
 	}
@@ -893,6 +918,7 @@  sfc_mae_encap_header_disable(struct sfc_adapter *sa,
 			     struct sfc_mae_encap_header *encap_header)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (encap_header == NULL)
@@ -915,8 +941,10 @@  sfc_mae_encap_header_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled encap_header=%p with EH_ID=0x%08x",
 				encap_header, fw_rsrc->eh_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable encap_header=%p with EH_ID=0x%08x: %s",
-				encap_header, fw_rsrc->eh_id.id, strerror(rc));
+				encap_header, fw_rsrc->eh_id.id, errmsg);
 		}
 		fw_rsrc->eh_id.id = EFX_MAE_RSRC_ID_INVALID;
 	}
@@ -993,6 +1021,7 @@  sfc_mae_counter_enable(struct sfc_adapter *sa, struct sfc_mae_counter *counter,
 		       efx_mae_actions_t *action_set_spec)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (counter == NULL)
@@ -1007,8 +1036,10 @@  sfc_mae_counter_enable(struct sfc_adapter *sa, struct sfc_mae_counter *counter,
 
 		rc = sfc_mae_counter_fw_rsrc_enable(sa, counter);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable counter=%p: %s",
-				counter, rte_strerror(rc));
+				counter, errmsg);
 			return rc;
 		}
 	}
@@ -1022,8 +1053,9 @@  sfc_mae_counter_enable(struct sfc_adapter *sa, struct sfc_mae_counter *counter,
 				fw_rsrc->counter_id.id = EFX_MAE_RSRC_ID_INVALID;
 			}
 
-			sfc_err(sa, "cannot fill in counter ID: %s",
-				strerror(rc));
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
+			sfc_err(sa, "cannot fill in counter ID: %s", errmsg);
 			return rc;
 		}
 	}
@@ -1042,6 +1074,7 @@  static void
 sfc_mae_counter_disable(struct sfc_adapter *sa, struct sfc_mae_counter *counter)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (counter == NULL)
@@ -1066,8 +1099,10 @@  sfc_mae_counter_disable(struct sfc_adapter *sa, struct sfc_mae_counter *counter)
 			sfc_dbg(sa, "disabled counter=%p with COUNTER_ID=0x%x-#%u",
 				counter, counter->type, counter_id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable counter=%p with COUNTER_ID=0x%x-#%u: %s",
-				counter, counter->type, counter_id, strerror(rc));
+				counter, counter->type, counter_id, errmsg);
 		}
 
 		fw_rsrc->counter_id.id = EFX_MAE_RSRC_ID_INVALID;
@@ -1178,6 +1213,7 @@  sfc_mae_action_set_enable(struct sfc_adapter *sa,
 	struct sfc_mae_mac_addr *src_mac_addr;
 	struct sfc_mae_counter *counter;
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (action_set == NULL)
@@ -1240,8 +1276,10 @@  sfc_mae_action_set_enable(struct sfc_adapter *sa,
 		rc = efx_mae_action_set_alloc(sa->nic, action_set->spec,
 					      &fw_rsrc->aset_id);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable action_set=%p: %s",
-				action_set, strerror(rc));
+				action_set, errmsg);
 
 			sfc_mae_encap_header_disable(sa, encap_header);
 			sfc_mae_mac_addr_disable(sa, src_mac_addr);
@@ -1264,6 +1302,7 @@  sfc_mae_action_set_disable(struct sfc_adapter *sa,
 			   struct sfc_mae_action_set *action_set)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (action_set == NULL)
@@ -1288,8 +1327,10 @@  sfc_mae_action_set_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled action_set=%p with AS_ID=0x%08x",
 				action_set, fw_rsrc->aset_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable action_set=%p with AS_ID=0x%08x: %s",
-				action_set, fw_rsrc->aset_id.id, strerror(rc));
+				action_set, fw_rsrc->aset_id.id, errmsg);
 		}
 		fw_rsrc->aset_id.id = EFX_MAE_RSRC_ID_INVALID;
 
@@ -1411,6 +1452,7 @@  sfc_mae_action_set_list_enable(struct sfc_adapter *sa,
 			       struct sfc_mae_action_set_list *action_set_list)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	unsigned int i;
 	unsigned int j;
 	int rc;
@@ -1444,8 +1486,10 @@  sfc_mae_action_set_list_enable(struct sfc_adapter *sa,
 						mae->bounce_aset_ids,
 						&fw_rsrc->aset_list_id);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to enable action_set_list=%p: %s",
-				action_set_list, strerror(rc));
+				action_set_list, errmsg);
 			goto fail_action_set_list_alloc;
 		}
 
@@ -1470,6 +1514,7 @@  sfc_mae_action_set_list_disable(struct sfc_adapter *sa,
 				struct sfc_mae_action_set_list *action_set_list)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (action_set_list == NULL)
@@ -1496,9 +1541,11 @@  sfc_mae_action_set_list_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled action_set_list=%p with ASL_ID=0x%08x",
 				action_set_list, fw_rsrc->aset_list_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable action_set_list=%p with ASL_ID=0x%08x: %s",
 				action_set_list, fw_rsrc->aset_list_id.id,
-				strerror(rc));
+				errmsg);
 		}
 		fw_rsrc->aset_list_id.id = EFX_MAE_RSRC_ID_INVALID;
 
@@ -1676,6 +1723,7 @@  sfc_mae_action_rule_enable(struct sfc_adapter *sa,
 {
 	const efx_mae_aset_list_id_t *asl_idp = NULL;
 	const efx_mae_aset_id_t *as_idp = NULL;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	struct sfc_mae_fw_rsrc *fw_rsrc;
 	int rc;
 
@@ -1707,8 +1755,10 @@  sfc_mae_action_rule_enable(struct sfc_adapter *sa,
 	rc = efx_mae_action_rule_insert(sa->nic, rule->match_spec, asl_idp,
 					as_idp, &fw_rsrc->rule_id);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to enable action_rule=%p: %s",
-			rule, strerror(rc));
+			rule, errmsg);
 		goto fail_action_rule_insert;
 	}
 
@@ -1739,6 +1789,7 @@  sfc_mae_action_rule_disable(struct sfc_adapter *sa,
 			    struct sfc_mae_action_rule *rule)
 {
 	struct sfc_mae_fw_rsrc *fw_rsrc;
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	SFC_ASSERT(sfc_adapter_is_locked(sa));
@@ -1758,8 +1809,10 @@  sfc_mae_action_rule_disable(struct sfc_adapter *sa,
 			sfc_dbg(sa, "disabled action_rule=%p with AR_ID=0x%08x",
 				rule, fw_rsrc->rule_id.id);
 		} else {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa, "failed to disable action_rule=%p with AR_ID=0x%08x: %s",
-				rule, fw_rsrc->rule_id.id, strerror(rc));
+				rule, fw_rsrc->rule_id.id, errmsg);
 		}
 
 		fw_rsrc->rule_id.id = EFX_MAE_RSRC_ID_INVALID;
@@ -4385,6 +4438,7 @@  sfc_mae_rule_parse_action_mark(struct sfc_adapter *sa,
 			       const struct sfc_flow_spec_mae *spec_mae,
 			       efx_mae_actions_t *spec)
 {
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if (spec_mae->ft_rule_type == SFC_FT_RULE_TUNNEL) {
@@ -4395,8 +4449,11 @@  sfc_mae_rule_parse_action_mark(struct sfc_adapter *sa,
 	}
 
 	rc = efx_mae_action_set_populate_mark(spec, conf->id);
-	if (rc != 0)
-		sfc_err(sa, "failed to request action MARK: %s", strerror(rc));
+	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
+		sfc_err(sa, "failed to request action MARK: %s", errmsg);
+	}
 
 	return rc;
 }
@@ -4409,6 +4466,7 @@  sfc_mae_rule_parse_action_count(struct sfc_adapter *sa,
 				efx_mae_actions_t *spec)
 {
 	struct sfc_mae_counter counter_tmp = {};
+	char errmsg[RTE_STRERR_BUFSIZE];
 	int rc;
 
 	if ((sa->counter_rxq.state & SFC_COUNTER_RXQ_INITIALIZED) == 0) {
@@ -4432,9 +4490,11 @@  sfc_mae_rule_parse_action_count(struct sfc_adapter *sa,
 	if (spec != NULL) {
 		rc = efx_mae_action_set_populate_count(spec);
 		if (rc != 0) {
+			if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+				snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 			sfc_err(sa,
 				"failed to populate counters in MAE action set: %s",
-				rte_strerror(rc));
+				errmsg);
 			goto fail_populate_count;
 		}
 	}
@@ -4555,6 +4615,7 @@  sfc_mae_rule_parse_action_pf_vf(struct sfc_adapter *sa,
 				efx_mae_actions_t *spec)
 {
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	char errmsg[RTE_STRERR_BUFSIZE];
 	efx_mport_sel_t mport;
 	uint32_t vf;
 	int rc;
@@ -4568,16 +4629,20 @@  sfc_mae_rule_parse_action_pf_vf(struct sfc_adapter *sa,
 
 	rc = efx_mae_mport_by_pcie_function(encp->enc_pf, vf, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to convert PF %u VF %d to m-port: %s",
 			encp->enc_pf, (vf != EFX_PCI_VF_INVALID) ? (int)vf : -1,
-			strerror(rc));
+			errmsg);
 		return rc;
 	}
 
 	rc = efx_mae_action_set_populate_deliver(spec, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
-			mport.sel, strerror(rc));
+			mport.sel, errmsg);
 	}
 
 	return rc;
@@ -4589,6 +4654,7 @@  sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa,
 				  efx_mae_actions_t *spec)
 {
 	struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+	char errmsg[RTE_STRERR_BUFSIZE];
 	struct sfc_mae *mae = &sa->mae;
 	unsigned int type_mask;
 	efx_mport_sel_t mport;
@@ -4605,15 +4671,19 @@  sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa,
 	rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id,
 					     port_id, type_mask, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
-			port_id, strerror(rc));
+			port_id, errmsg);
 		return rc;
 	}
 
 	rc = efx_mae_action_set_populate_deliver(spec, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
-			mport.sel, strerror(rc));
+			mport.sel, errmsg);
 	}
 
 	return rc;
@@ -4624,6 +4694,7 @@  sfc_mae_rule_parse_action_port_representor(struct sfc_adapter *sa,
 		const struct rte_flow_action_ethdev *conf,
 		unsigned int type_mask, efx_mae_actions_t *spec)
 {
+	char errmsg[RTE_STRERR_BUFSIZE];
 	struct sfc_mae *mae = &sa->mae;
 	efx_mport_sel_t mport;
 	int rc;
@@ -4631,15 +4702,19 @@  sfc_mae_rule_parse_action_port_representor(struct sfc_adapter *sa,
 	rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id,
 					     conf->port_id, type_mask, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
-			conf->port_id, strerror(rc));
+			conf->port_id, errmsg);
 		return rc;
 	}
 
 	rc = efx_mae_action_set_populate_deliver(spec, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
-			mport.sel, strerror(rc));
+			mport.sel, errmsg);
 	}
 
 	return rc;
@@ -4650,6 +4725,7 @@  sfc_mae_rule_parse_action_represented_port(struct sfc_adapter *sa,
 		const struct rte_flow_action_ethdev *conf,
 		efx_mae_actions_t *spec)
 {
+	char errmsg[RTE_STRERR_BUFSIZE];
 	struct sfc_mae *mae = &sa->mae;
 	efx_mport_sel_t mport;
 	int rc;
@@ -4657,15 +4733,19 @@  sfc_mae_rule_parse_action_represented_port(struct sfc_adapter *sa,
 	rc = sfc_mae_switch_get_entity_mport(mae->switch_domain_id,
 					     conf->port_id, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
-			conf->port_id, strerror(rc));
+			conf->port_id, errmsg);
 		return rc;
 	}
 
 	rc = efx_mae_action_set_populate_deliver(spec, &mport);
 	if (rc != 0) {
+		if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+			snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 		sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
-			mport.sel, strerror(rc));
+			mport.sel, errmsg);
 	}
 
 	return rc;
@@ -4750,6 +4830,8 @@  sfc_mae_rule_parse_action_rc(struct sfc_adapter *sa,
 			     struct rte_flow_error *error,
 			     int rc, bool custom_error)
 {
+	char errmsg[RTE_STRERR_BUFSIZE];
+
 	if (rc == 0) {
 		bundle->actions_mask |= (1ULL << action->type);
 	} else if (!custom_error) {
@@ -4757,8 +4839,10 @@  sfc_mae_rule_parse_action_rc(struct sfc_adapter *sa,
 			const char *action_name = action_names[action->type];
 
 			if (action_name != NULL) {
+				if (strerror_r(rc, errmsg, sizeof(errmsg)) != 0)
+					snprintf(errmsg, sizeof(errmsg), "Unknown error %d", rc);
 				sfc_err(sa, "action %s was rejected: %s",
-					action_name, strerror(rc));
+					action_name, errmsg);
 			}
 		}
 		rc = rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION,