[v3,02/42] eal: use rte strerror

Message ID 20231114123552.398072-3-huangdengdui@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: David Marchand
Headers
Series replace strerror |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dengdui Huang Nov. 14, 2023, 12:35 p.m. UTC
  The function strerror() is insecure in a multi-thread environment.
This patch uses rte_strerror() to replace it.

Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/common/eal_common_fbarray.c     |  2 +-
 lib/eal/common/eal_common_options.c     |  7 ++--
 lib/eal/common/eal_common_proc.c        | 12 +++----
 lib/eal/common/eal_common_trace_utils.c |  6 ++--
 lib/eal/freebsd/eal.c                   |  4 +--
 lib/eal/freebsd/eal_interrupts.c        |  8 ++---
 lib/eal/freebsd/eal_memory.c            |  2 +-
 lib/eal/freebsd/eal_timer.c             |  6 ++--
 lib/eal/linux/eal.c                     | 10 +++---
 lib/eal/linux/eal_dev.c                 |  2 +-
 lib/eal/linux/eal_hugepage_info.c       |  5 +--
 lib/eal/linux/eal_interrupts.c          | 18 +++++-----
 lib/eal/linux/eal_memalloc.c            | 47 +++++++++++++------------
 lib/eal/linux/eal_memory.c              | 43 +++++++++++-----------
 lib/eal/linux/eal_timer.c               |  2 +-
 lib/eal/linux/eal_vfio.c                | 40 ++++++++++-----------
 lib/eal/unix/eal_filesystem.c           |  5 +--
 lib/eal/unix/eal_unix_memory.c          |  6 ++--
 lib/eal/unix/rte_thread.c               |  6 ++--
 19 files changed, 118 insertions(+), 113 deletions(-)
  

Patch

diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
index 2055bfa57d..a2936bbd91 100644
--- a/lib/eal/common/eal_common_fbarray.c
+++ b/lib/eal/common/eal_common_fbarray.c
@@ -1027,7 +1027,7 @@  rte_fbarray_destroy(struct rte_fbarray *arr)
 		eal_get_fbarray_path(path, sizeof(path), arr->name);
 		if (unlink(path)) {
 			RTE_LOG(DEBUG, EAL, "Cannot unlink fbarray: %s\n",
-				strerror(errno));
+				rte_strerror(errno));
 			rte_errno = errno;
 			/*
 			 * we're still holding an exclusive lock, so drop it to
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index a6d21f1cba..8a09fe2719 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -44,6 +44,7 @@ 
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include "eal_trace.h"
 #endif
+#include <rte_errno.h>
 
 #define BITS_PER_HEX 4
 #define LCORE_OPT_LST 1
@@ -391,7 +392,7 @@  eal_plugindir_init(const char *path)
 	d = opendir(path);
 	if (d == NULL) {
 		RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
-			path, strerror(errno));
+			path, rte_strerror(errno));
 		return -1;
 	}
 
@@ -443,7 +444,7 @@  verify_perms(const char *dirpath)
 	/* call stat to check for permissions and ensure not world writable */
 	if (stat(dirpath, &st) != 0) {
 		RTE_LOG(ERR, EAL, "Error with stat on %s, %s\n",
-				dirpath, strerror(errno));
+				dirpath, rte_strerror(errno));
 		return -1;
 	}
 	if (st.st_mode & S_IWOTH) {
@@ -471,7 +472,7 @@  eal_dlopen(const char *pathname)
 	}
 	if (realp == NULL) {
 		RTE_LOG(ERR, EAL, "Error with realpath for %s, %s\n",
-				pathname, strerror(errno));
+				pathname, rte_strerror(errno));
 		goto out;
 	}
 	if (strnlen(realp, PATH_MAX) == PATH_MAX) {
diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
index 728815c4a9..2e39180d40 100644
--- a/lib/eal/common/eal_common_proc.c
+++ b/lib/eal/common/eal_common_proc.c
@@ -291,7 +291,7 @@  read_msg(int fd, struct mp_msg_internal *m, struct sockaddr_un *s)
 		if (errno == EINTR)
 			goto retry;
 
-		RTE_LOG(ERR, EAL, "recvmsg failed, %s\n", strerror(errno));
+		RTE_LOG(ERR, EAL, "recvmsg failed, %s\n", rte_strerror(errno));
 		return -1;
 	}
 
@@ -583,7 +583,7 @@  open_socket_fd(void)
 
 	if (bind(mp_fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
 		RTE_LOG(ERR, EAL, "failed to bind %s: %s\n",
-			un.sun_path, strerror(errno));
+			un.sun_path, rte_strerror(errno));
 		close(mp_fd);
 		return -1;
 	}
@@ -631,13 +631,13 @@  rte_mp_channel_init(void)
 	dir_fd = open(mp_dir_path, O_RDONLY);
 	if (dir_fd < 0) {
 		RTE_LOG(ERR, EAL, "failed to open %s: %s\n",
-			mp_dir_path, strerror(errno));
+			mp_dir_path, rte_strerror(errno));
 		return -1;
 	}
 
 	if (flock(dir_fd, LOCK_EX)) {
 		RTE_LOG(ERR, EAL, "failed to lock %s: %s\n",
-			mp_dir_path, strerror(errno));
+			mp_dir_path, rte_strerror(errno));
 		close(dir_fd);
 		return -1;
 	}
@@ -650,7 +650,7 @@  rte_mp_channel_init(void)
 	if (rte_thread_create_internal_control(&mp_handle_tid, "mp-msg",
 			mp_handle, NULL) < 0) {
 		RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n",
-			strerror(errno));
+			rte_strerror(errno));
 		close(dir_fd);
 		close(rte_atomic_exchange_explicit(&mp_fd, -1, rte_memory_order_relaxed));
 		return -1;
@@ -733,7 +733,7 @@  send_msg(const char *dst_path, struct rte_mp_msg *msg, int type)
 			return 0;
 		}
 		RTE_LOG(ERR, EAL, "failed to send to (%s) due to %s\n",
-			dst_path, strerror(errno));
+			dst_path, rte_strerror(errno));
 		return -1;
 	}
 
diff --git a/lib/eal/common/eal_common_trace_utils.c b/lib/eal/common/eal_common_trace_utils.c
index 8561a0e198..b74adf6589 100644
--- a/lib/eal/common/eal_common_trace_utils.c
+++ b/lib/eal/common/eal_common_trace_utils.c
@@ -244,7 +244,7 @@  eal_trace_dir_args_save(char const *val)
 	int rc;
 
 	if (asprintf(&dir_path, "%s/", val) == -1) {
-		trace_err("failed to copy directory: %s", strerror(errno));
+		trace_err("failed to copy directory: %s", rte_strerror(errno));
 		return -ENOMEM;
 	}
 
@@ -328,7 +328,7 @@  trace_mkdir(void)
 	/* Create the path if it t exist, no "mkdir -p" available here */
 	rc = mkdir(trace->dir, 0700);
 	if (rc < 0 && errno != EEXIST) {
-		trace_err("mkdir %s failed [%s]", trace->dir, strerror(errno));
+		trace_err("mkdir %s failed [%s]", trace->dir, rte_strerror(errno));
 		rte_errno = errno;
 		return -rte_errno;
 	}
@@ -343,7 +343,7 @@  trace_mkdir(void)
 
 	rc = mkdir(trace->dir, 0700);
 	if (rc < 0) {
-		trace_err("mkdir %s failed [%s]", trace->dir, strerror(errno));
+		trace_err("mkdir %s failed [%s]", trace->dir, rte_strerror(errno));
 		rte_errno = errno;
 		return -rte_errno;
 	}
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 568e06e9ed..a82f3ab8d0 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -203,7 +203,7 @@  rte_eal_config_attach(void)
 		close(mem_cfg_fd);
 		mem_cfg_fd = -1;
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
@@ -250,7 +250,7 @@  rte_eal_config_reattach(void)
 			return -1;
 		}
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 2b31dfb099..0672e88e4e 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -186,7 +186,7 @@  rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
 			else
 				RTE_LOG(ERR, EAL, "Error adding fd %d kevent, %s\n",
 					rte_intr_fd_get(src->intr_handle),
-					strerror(errno));
+					rte_strerror(errno));
 			ret = -errno;
 			goto fail;
 		}
@@ -323,7 +323,7 @@  rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
 		if (kevent(kq, &ke, 1, NULL, 0, NULL) < 0) {
 			RTE_LOG(ERR, EAL, "Error removing fd %d kevent, %s\n",
 				rte_intr_fd_get(src->intr_handle),
-				strerror(errno));
+				rte_strerror(errno));
 			/* removing non-existent even is an expected condition
 			 * in some circumstances (e.g. oneshot events).
 			 */
@@ -516,7 +516,7 @@  eal_intr_process_interrupts(struct kevent *events, int nfds)
 				RTE_LOG(ERR, EAL, "Error reading from file "
 					"descriptor %d: %s\n",
 					event_fd,
-					strerror(errno));
+					rte_strerror(errno));
 			} else if (bytes_read == 0)
 				RTE_LOG(ERR, EAL, "Read nothing from file "
 					"descriptor %d\n", event_fd);
@@ -567,7 +567,7 @@  eal_intr_process_interrupts(struct kevent *events, int nfds)
 				if (kevent(kq, &ke, 1, NULL, 0, NULL) < 0) {
 					RTE_LOG(ERR, EAL, "Error removing fd %d kevent, %s\n",
 						rte_intr_fd_get(src->intr_handle),
-						strerror(errno));
+						rte_strerror(errno));
 					/* removing non-existent even is an expected
 					 * condition in some circumstances
 					 * (e.g. oneshot events).
diff --git a/lib/eal/freebsd/eal_memory.c b/lib/eal/freebsd/eal_memory.c
index 5c6165c580..35e11970c6 100644
--- a/lib/eal/freebsd/eal_memory.c
+++ b/lib/eal/freebsd/eal_memory.c
@@ -85,7 +85,7 @@  rte_eal_hugepage_init(void)
 				MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 		if (addr == MAP_FAILED) {
 			RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
-					strerror(errno));
+					rte_strerror(errno));
 			return -1;
 		}
 
diff --git a/lib/eal/freebsd/eal_timer.c b/lib/eal/freebsd/eal_timer.c
index beff755a47..7125e4e0e8 100644
--- a/lib/eal/freebsd/eal_timer.c
+++ b/lib/eal/freebsd/eal_timer.c
@@ -36,20 +36,20 @@  get_tsc_freq(void)
 	tmp = 0;
 
 	if (sysctlbyname("kern.timecounter.smp_tsc", &tmp, &sz, NULL, 0))
-		RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
+		RTE_LOG(WARNING, EAL, "%s\n", rte_strerror(errno));
 	else if (tmp != 1)
 		RTE_LOG(WARNING, EAL, "TSC is not safe to use in SMP mode\n");
 
 	tmp = 0;
 
 	if (sysctlbyname("kern.timecounter.invariant_tsc", &tmp, &sz, NULL, 0))
-		RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
+		RTE_LOG(WARNING, EAL, "%s\n", rte_strerror(errno));
 	else if (tmp != 1)
 		RTE_LOG(WARNING, EAL, "TSC is not invariant\n");
 
 	sz = sizeof(tsc_hz);
 	if (sysctlbyname("machdep.tsc_freq", &tsc_hz, &sz, NULL, 0)) {
-		RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
+		RTE_LOG(WARNING, EAL, "%s\n", rte_strerror(errno));
 		return 0;
 	}
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 57da058cec..0da0a000ac 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -160,7 +160,7 @@  eal_clean_runtime_dir(void)
 		closedir(dir);
 
 	RTE_LOG(ERR, EAL, "Error while clearing runtime dir: %s\n",
-		strerror(errno));
+		rte_strerror(errno));
 
 	return -1;
 }
@@ -288,7 +288,7 @@  rte_eal_config_attach(void)
 		close(mem_cfg_fd);
 		mem_cfg_fd = -1;
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
@@ -335,7 +335,7 @@  rte_eal_config_reattach(void)
 			return -1;
 		}
 		RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
@@ -1421,7 +1421,7 @@  rte_eal_check_module(const char *module_name)
 	/* Check if there is sysfs mounted */
 	if (stat("/sys/module", &st) != 0) {
 		RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
@@ -1434,7 +1434,7 @@  rte_eal_check_module(const char *module_name)
 
 	if (stat(sysfs_mod_name, &st) != 0) {
 		RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n",
-		        sysfs_mod_name, errno, strerror(errno));
+			sysfs_mod_name, errno, rte_strerror(errno));
 		return 0;
 	}
 
diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c
index ac76f6174d..ede68f32cf 100644
--- a/lib/eal/linux/eal_dev.c
+++ b/lib/eal/linux/eal_dev.c
@@ -73,7 +73,7 @@  static void sigbus_handler(int signum, siginfo_t *info,
 	if (ret == -1) {
 		rte_exit(EXIT_FAILURE,
 			 "Failed to handle SIGBUS for hot-unplug, "
-			 "(rte_errno: %s)!", strerror(rte_errno));
+			 "(rte_errno: %s)!", rte_strerror(rte_errno));
 	} else if (ret == 1) {
 		if (sigbus_action_old.sa_flags == SA_SIGINFO
 		    && sigbus_action_old.sa_sigaction) {
diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c
index 581d9dfc91..6286ab3efb 100644
--- a/lib/eal/linux/eal_hugepage_info.c
+++ b/lib/eal/linux/eal_hugepage_info.c
@@ -23,6 +23,7 @@ 
 #include <rte_log.h>
 #include <rte_common.h>
 #include "rte_string_fns.h"
+#include <rte_errno.h>
 
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
@@ -378,7 +379,7 @@  walk_hugedir(const char *hugedir, walk_hugedir_t *cb, void *user_data)
 		closedir(dir);
 
 	RTE_LOG(ERR, EAL, "Error while walking hugepage dir: %s\n",
-		strerror(errno));
+		rte_strerror(errno));
 
 	return -1;
 }
@@ -404,7 +405,7 @@  inspect_hugedir_cb(const struct walk_hugedir_data *whd)
 
 	if (fstat(whd->file_fd, &st) < 0)
 		RTE_LOG(DEBUG, EAL, "%s(): stat(\"%s\") failed: %s",
-				__func__, whd->file_name, strerror(errno));
+				__func__, whd->file_name, rte_strerror(errno));
 	else
 		(*total_size) += st.st_size;
 }
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index d4919dff45..660e64dd41 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -460,7 +460,7 @@  uio_intr_disable(const struct rte_intr_handle *intr_handle)
 	if (rte_intr_fd_get(intr_handle) < 0 ||
 	    write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
 		RTE_LOG(ERR, EAL, "Error disabling interrupts for fd %d (%s)\n",
-			rte_intr_fd_get(intr_handle), strerror(errno));
+			rte_intr_fd_get(intr_handle), rte_strerror(errno));
 		return -1;
 	}
 	return 0;
@@ -474,7 +474,7 @@  uio_intr_enable(const struct rte_intr_handle *intr_handle)
 	if (rte_intr_fd_get(intr_handle) < 0 ||
 	    write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
 		RTE_LOG(ERR, EAL, "Error enabling interrupts for fd %d (%s)\n",
-			rte_intr_fd_get(intr_handle), strerror(errno));
+			rte_intr_fd_get(intr_handle), rte_strerror(errno));
 		return -1;
 	}
 	return 0;
@@ -975,7 +975,7 @@  eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 				RTE_LOG(ERR, EAL, "Error reading from file "
 					"descriptor %d: %s\n",
 					events[n].data.fd,
-					strerror(errno));
+					rte_strerror(errno));
 				/*
 				 * The device is unplugged or buggy, remove
 				 * it as an interrupt source and return to
@@ -1130,7 +1130,7 @@  eal_intr_thread_main(__rte_unused void *arg)
 		if (epoll_ctl(pfd, EPOLL_CTL_ADD, intr_pipe.readfd,
 						&pipe_event) < 0) {
 			rte_panic("Error adding fd to %d epoll_ctl, %s\n",
-					intr_pipe.readfd, strerror(errno));
+					intr_pipe.readfd, rte_strerror(errno));
 		}
 		numfds++;
 
@@ -1153,7 +1153,7 @@  eal_intr_thread_main(__rte_unused void *arg)
 					rte_intr_fd_get(src->intr_handle), &ev) < 0) {
 				rte_panic("Error adding fd %d epoll_ctl, %s\n",
 					rte_intr_fd_get(src->intr_handle),
-					strerror(errno));
+					rte_strerror(errno));
 			}
 			else
 				numfds++;
@@ -1244,7 +1244,7 @@  eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)
 				continue;
 			RTE_LOG(ERR, EAL,
 				"Error reading from fd %d: %s\n",
-				fd, strerror(errno));
+				fd, rte_strerror(errno));
 		} else if (nbytes == 0)
 			RTE_LOG(ERR, EAL, "Read nothing from fd %d\n", fd);
 		return;
@@ -1343,7 +1343,7 @@  eal_epoll_wait(int epfd, struct rte_epoll_event *events,
 			}
 			/* epoll_wait fail */
 			RTE_LOG(ERR, EAL, "epoll_wait returns with fail %s\n",
-				strerror(errno));
+				rte_strerror(errno));
 			rc = -1;
 			break;
 		} else {
@@ -1412,7 +1412,7 @@  rte_epoll_ctl(int epfd, int op, int fd,
 	ev.events = event->epdata.event;
 	if (epoll_ctl(epfd, op, fd, &ev) < 0) {
 		RTE_LOG(ERR, EAL, "Error op %d fd %d epoll_ctl, %s\n",
-			op, fd, strerror(errno));
+			op, fd, rte_strerror(errno));
 		if (op == EPOLL_CTL_ADD)
 			/* rollback status when CTL_ADD fail */
 			rte_atomic_store_explicit(&event->status, RTE_EPOLL_INVALID,
@@ -1525,7 +1525,7 @@  rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)
 			if (fd < 0) {
 				RTE_LOG(ERR, EAL,
 					"can't setup eventfd, error %i (%s)\n",
-					errno, strerror(errno));
+					errno, rte_strerror(errno));
 				return -errno;
 			}
 
diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
index 9853ec78a2..53a7e5dd3b 100644
--- a/lib/eal/linux/eal_memalloc.c
+++ b/lib/eal/linux/eal_memalloc.c
@@ -31,6 +31,7 @@ 
 #include <rte_log.h>
 #include <rte_eal.h>
 #include <rte_memory.h>
+#include <rte_errno.h>
 
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
@@ -161,7 +162,7 @@  prepare_numa(int *oldpolicy, struct bitmask *oldmask, int socket_id)
 			  oldmask->size + 1, 0, 0) < 0) {
 		RTE_LOG(ERR, EAL,
 			"Failed to get current mempolicy: %s. "
-			"Assuming MPOL_DEFAULT.\n", strerror(errno));
+			"Assuming MPOL_DEFAULT.\n", rte_strerror(errno));
 		*oldpolicy = MPOL_DEFAULT;
 	}
 	RTE_LOG(DEBUG, EAL,
@@ -180,7 +181,7 @@  restore_numa(int *oldpolicy, struct bitmask *oldmask)
 	} else if (set_mempolicy(*oldpolicy, oldmask->maskp,
 				 oldmask->size + 1) < 0) {
 		RTE_LOG(ERR, EAL, "Failed to restore mempolicy: %s\n",
-			strerror(errno));
+			rte_strerror(errno));
 		numa_set_localalloc();
 	}
 	numa_free_cpumask(oldmask);
@@ -224,7 +225,7 @@  static int lock(int fd, int type)
 		return 0;
 	} else if (ret) {
 		RTE_LOG(ERR, EAL, "%s(): error calling flock(): %s\n",
-			__func__, strerror(errno));
+			__func__, rte_strerror(errno));
 		return -1;
 	}
 	/* lock was successful */
@@ -252,7 +253,7 @@  get_seg_memfd(struct hugepage_info *hi __rte_unused,
 			fd = memfd_create(segname, flags);
 			if (fd < 0) {
 				RTE_LOG(DEBUG, EAL, "%s(): memfd create failed: %s\n",
-					__func__, strerror(errno));
+					__func__, rte_strerror(errno));
 				return -1;
 			}
 			fd_list[list_idx].memseg_list_fd = fd;
@@ -266,7 +267,7 @@  get_seg_memfd(struct hugepage_info *hi __rte_unused,
 			fd = memfd_create(segname, flags);
 			if (fd < 0) {
 				RTE_LOG(DEBUG, EAL, "%s(): memfd create failed: %s\n",
-					__func__, strerror(errno));
+					__func__, rte_strerror(errno));
 				return -1;
 			}
 			fd_list[list_idx].fds[seg_idx] = fd;
@@ -317,7 +318,7 @@  get_seg_fd(char *path, int buflen, struct hugepage_info *hi,
 	ret = stat(path, &st);
 	if (ret < 0 && errno != ENOENT) {
 		RTE_LOG(DEBUG, EAL, "%s(): stat() for '%s' failed: %s\n",
-			__func__, path, strerror(errno));
+			__func__, path, rte_strerror(errno));
 		return -1;
 	}
 	if (!internal_conf->hugepage_file.unlink_existing && ret == 0 &&
@@ -343,7 +344,7 @@  get_seg_fd(char *path, int buflen, struct hugepage_info *hi,
 		/* coverity[toctou] */
 		if (unlink(path) < 0) {
 			RTE_LOG(DEBUG, EAL, "%s(): could not remove '%s': %s\n",
-				__func__, path, strerror(errno));
+				__func__, path, rte_strerror(errno));
 			return -1;
 		}
 	}
@@ -352,13 +353,13 @@  get_seg_fd(char *path, int buflen, struct hugepage_info *hi,
 	fd = open(path, O_CREAT | O_RDWR, 0600);
 	if (fd < 0) {
 		RTE_LOG(ERR, EAL, "%s(): open '%s' failed: %s\n",
-			__func__, path, strerror(errno));
+			__func__, path, rte_strerror(errno));
 		return -1;
 	}
 	/* take out a read lock */
 	if (lock(fd, LOCK_SH) < 0) {
 		RTE_LOG(ERR, EAL, "%s(): lock '%s' failed: %s\n",
-			__func__, path, strerror(errno));
+			__func__, path, rte_strerror(errno));
 		close(fd);
 		return -1;
 	}
@@ -380,7 +381,7 @@  resize_hugefile_in_memory(int fd, uint64_t fa_offset,
 	if (ret < 0) {
 		RTE_LOG(DEBUG, EAL, "%s(): fallocate() failed: %s\n",
 				__func__,
-				strerror(errno));
+				rte_strerror(errno));
 		return -1;
 	}
 	return 0;
@@ -415,7 +416,7 @@  resize_hugefile_in_filesystem(int fd, uint64_t fa_offset, uint64_t page_sz,
 			if (new_size > cur_size &&
 					ftruncate(fd, new_size) < 0) {
 				RTE_LOG(DEBUG, EAL, "%s(): ftruncate() failed: %s\n",
-					__func__, strerror(errno));
+					__func__, rte_strerror(errno));
 				return -1;
 			}
 		} else {
@@ -451,7 +452,7 @@  resize_hugefile_in_filesystem(int fd, uint64_t fa_offset, uint64_t page_sz,
 				} else {
 					RTE_LOG(DEBUG, EAL, "%s(): fallocate() failed: %s\n",
 						__func__,
-						strerror(errno));
+						rte_strerror(errno));
 					return -1;
 				}
 			} else {
@@ -484,7 +485,7 @@  close_hugefile(int fd, char *path, int list_idx)
 			rte_eal_process_type() == RTE_PROC_PRIMARY &&
 			unlink(path))
 		RTE_LOG(ERR, EAL, "%s(): unlinking '%s' failed: %s\n",
-			__func__, path, strerror(errno));
+			__func__, path, rte_strerror(errno));
 
 	close(fd);
 	fd_list[list_idx].memseg_list_fd = -1;
@@ -585,14 +586,14 @@  alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 			map_offset = 0;
 			if (ftruncate(fd, alloc_sz) < 0) {
 				RTE_LOG(DEBUG, EAL, "%s(): ftruncate() failed: %s\n",
-					__func__, strerror(errno));
+					__func__, rte_strerror(errno));
 				goto resized;
 			}
 			if (internal_conf->hugepage_file.unlink_before_mapping &&
 					!internal_conf->in_memory) {
 				if (unlink(path)) {
 					RTE_LOG(DEBUG, EAL, "%s(): unlink() failed: %s\n",
-						__func__, strerror(errno));
+						__func__, rte_strerror(errno));
 					goto resized;
 				}
 			}
@@ -611,7 +612,7 @@  alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 
 	if (va == MAP_FAILED) {
 		RTE_LOG(DEBUG, EAL, "%s(): mmap() failed: %s\n", __func__,
-			strerror(errno));
+			rte_strerror(errno));
 		/* mmap failed, but the previous region might have been
 		 * unmapped anyway. try to remap it
 		 */
@@ -662,7 +663,7 @@  alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 					MPOL_F_NODE | MPOL_F_ADDR);
 		if (ret < 0) {
 			RTE_LOG(DEBUG, EAL, "%s(): get_mempolicy: %s\n",
-				__func__, strerror(errno));
+				__func__, rte_strerror(errno));
 			goto mapped;
 		} else if (cur_socket_id != socket_id) {
 			RTE_LOG(DEBUG, EAL,
@@ -874,13 +875,13 @@  alloc_seg_walk(const struct rte_memseg_list *msl, void *arg)
 		dir_fd = open(wa->hi->hugedir, O_RDONLY);
 		if (dir_fd < 0) {
 			RTE_LOG(ERR, EAL, "%s(): Cannot open '%s': %s\n",
-				__func__, wa->hi->hugedir, strerror(errno));
+				__func__, wa->hi->hugedir, rte_strerror(errno));
 			return -1;
 		}
 		/* blocking writelock */
 		if (flock(dir_fd, LOCK_EX)) {
 			RTE_LOG(ERR, EAL, "%s(): Cannot lock '%s': %s\n",
-				__func__, wa->hi->hugedir, strerror(errno));
+				__func__, wa->hi->hugedir, rte_strerror(errno));
 			close(dir_fd);
 			return -1;
 		}
@@ -981,13 +982,13 @@  free_seg_walk(const struct rte_memseg_list *msl, void *arg)
 		dir_fd = open(wa->hi->hugedir, O_RDONLY);
 		if (dir_fd < 0) {
 			RTE_LOG(ERR, EAL, "%s(): Cannot open '%s': %s\n",
-				__func__, wa->hi->hugedir, strerror(errno));
+				__func__, wa->hi->hugedir, rte_strerror(errno));
 			return -1;
 		}
 		/* blocking writelock */
 		if (flock(dir_fd, LOCK_EX)) {
 			RTE_LOG(ERR, EAL, "%s(): Cannot lock '%s': %s\n",
-				__func__, wa->hi->hugedir, strerror(errno));
+				__func__, wa->hi->hugedir, rte_strerror(errno));
 			close(dir_fd);
 			return -1;
 		}
@@ -1345,13 +1346,13 @@  sync_existing(struct rte_memseg_list *primary_msl,
 	dir_fd = open(hi->hugedir, O_RDONLY);
 	if (dir_fd < 0) {
 		RTE_LOG(ERR, EAL, "%s(): Cannot open '%s': %s\n", __func__,
-			hi->hugedir, strerror(errno));
+			hi->hugedir, rte_strerror(errno));
 		return -1;
 	}
 	/* blocking writelock */
 	if (flock(dir_fd, LOCK_EX)) {
 		RTE_LOG(ERR, EAL, "%s(): Cannot lock '%s': %s\n", __func__,
-			hi->hugedir, strerror(errno));
+			hi->hugedir, rte_strerror(errno));
 		close(dir_fd);
 		return -1;
 	}
diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c
index 9b6f08fba8..db92d1a602 100644
--- a/lib/eal/linux/eal_memory.c
+++ b/lib/eal/linux/eal_memory.c
@@ -105,7 +105,7 @@  rte_mem_virt2phy(const void *virtaddr)
 	fd = open("/proc/self/pagemap", O_RDONLY);
 	if (fd < 0) {
 		RTE_LOG(INFO, EAL, "%s(): cannot open /proc/self/pagemap: %s\n",
-			__func__, strerror(errno));
+			__func__, rte_strerror(errno));
 		return RTE_BAD_IOVA;
 	}
 
@@ -113,7 +113,7 @@  rte_mem_virt2phy(const void *virtaddr)
 	offset = sizeof(uint64_t) * virt_pfn;
 	if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
 		RTE_LOG(INFO, EAL, "%s(): seek error in /proc/self/pagemap: %s\n",
-				__func__, strerror(errno));
+				__func__, rte_strerror(errno));
 		close(fd);
 		return RTE_BAD_IOVA;
 	}
@@ -122,7 +122,7 @@  rte_mem_virt2phy(const void *virtaddr)
 	close(fd);
 	if (retval < 0) {
 		RTE_LOG(INFO, EAL, "%s(): cannot read /proc/self/pagemap: %s\n",
-				__func__, strerror(errno));
+				__func__, rte_strerror(errno));
 		return RTE_BAD_IOVA;
 	} else if (retval != PFN_MASK_SIZE) {
 		RTE_LOG(INFO, EAL, "%s(): read %d bytes from /proc/self/pagemap "
@@ -237,7 +237,7 @@  static int huge_wrap_sigsetjmp(void)
 /* Callback for numa library. */
 void numa_error(char *where)
 {
-	RTE_LOG(ERR, EAL, "%s failed: %s\n", where, strerror(errno));
+	RTE_LOG(ERR, EAL, "%s failed: %s\n", where, rte_strerror(errno));
 }
 #endif
 
@@ -278,7 +278,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
 				  oldmask->size + 1, 0, 0) < 0) {
 			RTE_LOG(ERR, EAL,
 				"Failed to get current mempolicy: %s. "
-				"Assuming MPOL_DEFAULT.\n", strerror(errno));
+				"Assuming MPOL_DEFAULT.\n", rte_strerror(errno));
 			oldpolicy = MPOL_DEFAULT;
 		}
 		for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
@@ -333,7 +333,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
 		fd = open(hf->filepath, O_CREAT | O_RDWR, 0600);
 		if (fd < 0) {
 			RTE_LOG(DEBUG, EAL, "%s(): open failed: %s\n", __func__,
-					strerror(errno));
+					rte_strerror(errno));
 			goto out;
 		}
 
@@ -346,7 +346,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
 				MAP_SHARED | MAP_POPULATE, fd, 0);
 		if (virtaddr == MAP_FAILED) {
 			RTE_LOG(DEBUG, EAL, "%s(): mmap failed: %s\n", __func__,
-					strerror(errno));
+					rte_strerror(errno));
 			close(fd);
 			goto out;
 		}
@@ -379,7 +379,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
 		/* set shared lock on the file. */
 		if (flock(fd, LOCK_SH) < 0) {
 			RTE_LOG(DEBUG, EAL, "%s(): Locking file failed:%s \n",
-				__func__, strerror(errno));
+				__func__, rte_strerror(errno));
 			close(fd);
 			goto out;
 		}
@@ -397,7 +397,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,
 		} else if (set_mempolicy(oldpolicy, oldmask->maskp,
 					 oldmask->size + 1) < 0) {
 			RTE_LOG(ERR, EAL, "Failed to restore mempolicy: %s\n",
-				strerror(errno));
+				rte_strerror(errno));
 			numa_set_localalloc();
 		}
 	}
@@ -590,7 +590,7 @@  unlink_hugepage_files(struct hugepage_file *hugepg_tbl,
 
 		if (hp->orig_va != NULL && unlink(hp->filepath)) {
 			RTE_LOG(WARNING, EAL, "%s(): Removing %s failed: %s\n",
-				__func__, hp->filepath, strerror(errno));
+				__func__, hp->filepath, rte_strerror(errno));
 		}
 	}
 	return 0;
@@ -640,7 +640,8 @@  unmap_unneeded_hugepages(struct hugepage_file *hugepg_tbl,
 						hp->orig_va = NULL;
 						if (unlink(hp->filepath) == -1) {
 							RTE_LOG(ERR, EAL, "%s(): Removing %s failed: %s\n",
-									__func__, hp->filepath, strerror(errno));
+								__func__, hp->filepath,
+								rte_strerror(errno));
 							return -1;
 						}
 					} else {
@@ -736,13 +737,13 @@  remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end)
 		fd = open(hfile->filepath, O_RDWR);
 		if (fd < 0) {
 			RTE_LOG(ERR, EAL, "Could not open '%s': %s\n",
-					hfile->filepath, strerror(errno));
+					hfile->filepath, rte_strerror(errno));
 			return -1;
 		}
 		/* set shared lock on the file. */
 		if (flock(fd, LOCK_SH) < 0) {
 			RTE_LOG(DEBUG, EAL, "Could not lock '%s': %s\n",
-					hfile->filepath, strerror(errno));
+					hfile->filepath, rte_strerror(errno));
 			close(fd);
 			return -1;
 		}
@@ -756,7 +757,7 @@  remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end)
 				MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd, 0);
 		if (addr == MAP_FAILED) {
 			RTE_LOG(ERR, EAL, "Couldn't remap '%s': %s\n",
-					hfile->filepath, strerror(errno));
+					hfile->filepath, rte_strerror(errno));
 			close(fd);
 			return -1;
 		}
@@ -1178,13 +1179,13 @@  eal_legacy_hugepage_init(void)
 		memfd = memfd_create("nohuge", 0);
 		if (memfd < 0) {
 			RTE_LOG(DEBUG, EAL, "Cannot create memfd: %s\n",
-					strerror(errno));
+					rte_strerror(errno));
 			RTE_LOG(DEBUG, EAL, "Falling back to anonymous map\n");
 		} else {
 			/* we got an fd - now resize it */
 			if (ftruncate(memfd, internal_conf->memory) < 0) {
 				RTE_LOG(ERR, EAL, "Cannot resize memfd: %s\n",
-						strerror(errno));
+						rte_strerror(errno));
 				RTE_LOG(ERR, EAL, "Falling back to anonymous map\n");
 				close(memfd);
 			} else {
@@ -1212,7 +1213,7 @@  eal_legacy_hugepage_init(void)
 				flags | MAP_FIXED, fd, 0);
 		if (addr == MAP_FAILED || addr != prealloc_addr) {
 			RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__,
-					strerror(errno));
+					rte_strerror(errno));
 			munmap(prealloc_addr, mem_sz);
 			return -1;
 		}
@@ -1571,7 +1572,7 @@  eal_legacy_hugepage_attach(void)
 		fd = open(hf->filepath, O_RDWR);
 		if (fd < 0) {
 			RTE_LOG(ERR, EAL, "Could not open %s: %s\n",
-				hf->filepath, strerror(errno));
+				hf->filepath, rte_strerror(errno));
 			goto error;
 		}
 
@@ -1579,14 +1580,14 @@  eal_legacy_hugepage_attach(void)
 				MAP_SHARED | MAP_FIXED, fd, 0);
 		if (map_addr == MAP_FAILED) {
 			RTE_LOG(ERR, EAL, "Could not map %s: %s\n",
-				hf->filepath, strerror(errno));
+				hf->filepath, rte_strerror(errno));
 			goto fd_error;
 		}
 
 		/* set shared lock on the file. */
 		if (flock(fd, LOCK_SH) < 0) {
 			RTE_LOG(DEBUG, EAL, "%s(): Locking file failed: %s\n",
-				__func__, strerror(errno));
+				__func__, rte_strerror(errno));
 			goto mmap_error;
 		}
 
@@ -1931,7 +1932,7 @@  rte_eal_memseg_init(void)
 
 		if (setrlimit(RLIMIT_NOFILE, &lim) < 0) {
 			RTE_LOG(DEBUG, EAL, "Setting maximum number of open files failed: %s\n",
-					strerror(errno));
+					rte_strerror(errno));
 		} else {
 			RTE_LOG(DEBUG, EAL, "Setting maximum number of open files to %"
 					PRIu64 "\n",
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 3a30284e3a..c80e87309c 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -146,7 +146,7 @@  rte_eal_hpet_init(int make_default)
 	fd = open(DEV_HPET, O_RDONLY);
 	if (fd < 0) {
 		RTE_LOG(ERR, EAL, "ERROR: Cannot open "DEV_HPET": %s!\n",
-			strerror(errno));
+			rte_strerror(errno));
 		internal_conf->no_hpet = 1;
 		return -1;
 	}
diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c
index ad3c1654b2..c18d4ee8ab 100644
--- a/lib/eal/linux/eal_vfio.c
+++ b/lib/eal/linux/eal_vfio.c
@@ -368,7 +368,7 @@  vfio_open_group_fd(int iommu_group_num)
 			/* if file not found, it's not an error */
 			if (errno != ENOENT) {
 				RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
-						filename, strerror(errno));
+						filename, rte_strerror(errno));
 				return -1;
 			}
 
@@ -381,7 +381,7 @@  vfio_open_group_fd(int iommu_group_num)
 				if (errno != ENOENT) {
 					RTE_LOG(ERR, EAL,
 						"Cannot open %s: %s\n",
-						filename, strerror(errno));
+						filename, rte_strerror(errno));
 					return -1;
 				}
 				return -ENOENT;
@@ -791,7 +791,7 @@  rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 	ret = ioctl(vfio_group_fd, VFIO_GROUP_GET_STATUS, &group_status);
 	if (ret) {
 		RTE_LOG(ERR, EAL, "%s cannot get VFIO group status, "
-			"error %i (%s)\n", dev_addr, errno, strerror(errno));
+			"error %i (%s)\n", dev_addr, errno, rte_strerror(errno));
 		close(vfio_group_fd);
 		rte_vfio_clear_group(vfio_group_fd);
 		return -1;
@@ -819,7 +819,7 @@  rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		if (ret) {
 			RTE_LOG(ERR, EAL,
 				"%s cannot add VFIO group to container, error "
-				"%i (%s)\n", dev_addr, errno, strerror(errno));
+				"%i (%s)\n", dev_addr, errno, rte_strerror(errno));
 			close(vfio_group_fd);
 			rte_vfio_clear_group(vfio_group_fd);
 			return -1;
@@ -860,7 +860,7 @@  rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 				RTE_LOG(ERR, EAL,
 					"%s DMA remapping failed, error "
 					"%i (%s)\n",
-					dev_addr, errno, strerror(errno));
+					dev_addr, errno, rte_strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
 				rte_mcfg_mem_read_unlock();
@@ -978,7 +978,7 @@  rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 	if (ret) {
 		RTE_LOG(ERR, EAL, "%s cannot get device info, "
 				"error %i (%s)\n", dev_addr, errno,
-				strerror(errno));
+				rte_strerror(errno));
 		close(*vfio_dev_fd);
 		close(vfio_group_fd);
 		rte_vfio_clear_group(vfio_group_fd);
@@ -1216,7 +1216,7 @@  vfio_set_iommu_type(int vfio_container_fd)
 		/* not an error, there may be more supported IOMMU types */
 		RTE_LOG(DEBUG, EAL, "Set IOMMU type %d (%s) failed, error "
 				"%i (%s)\n", t->type_id, t->name, errno,
-				strerror(errno));
+				rte_strerror(errno));
 	}
 	/* if we didn't find a suitable IOMMU type, fail */
 	return NULL;
@@ -1234,7 +1234,7 @@  vfio_has_supported_extensions(int vfio_container_fd)
 				t->type_id);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Could not get IOMMU type, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			close(vfio_container_fd);
 			return -1;
 		} else if (ret == 1) {
@@ -1274,7 +1274,7 @@  rte_vfio_get_container_fd(void)
 			RTE_LOG(ERR, EAL,
 					"Cannot open VFIO container %s, error "
 					"%i (%s)\n", VFIO_CONTAINER_PATH,
-					errno, strerror(errno));
+					errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -1284,7 +1284,7 @@  rte_vfio_get_container_fd(void)
 			if (ret < 0)
 				RTE_LOG(ERR, EAL,
 					"Could not get VFIO API version, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			else
 				RTE_LOG(ERR, EAL, "Unsupported VFIO API version!\n");
 			close(vfio_container_fd);
@@ -1416,7 +1416,7 @@  vfio_type1_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 			} else {
 				RTE_LOG(ERR, EAL,
 					"Cannot set up DMA remapping, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 				return -1;
 			}
 		}
@@ -1430,7 +1430,7 @@  vfio_type1_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 				&dma_unmap);
 		if (ret) {
 			RTE_LOG(ERR, EAL, "Cannot clear DMA remapping, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		} else if (dma_unmap.size != len) {
 			RTE_LOG(ERR, EAL, "Unexpected size %"PRIu64
@@ -1479,7 +1479,7 @@  vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 		if (ret) {
 			RTE_LOG(ERR, EAL,
 				"Cannot register vaddr for IOMMU, error "
-				"%i (%s)\n", errno, strerror(errno));
+				"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -1494,7 +1494,7 @@  vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 		ret = ioctl(vfio_container_fd, VFIO_IOMMU_MAP_DMA, &dma_map);
 		if (ret) {
 			RTE_LOG(ERR, EAL, "Cannot map vaddr for IOMMU, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -1510,7 +1510,7 @@  vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 				&dma_unmap);
 		if (ret) {
 			RTE_LOG(ERR, EAL, "Cannot unmap vaddr for IOMMU, error "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		}
 
@@ -1519,7 +1519,7 @@  vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
 		if (ret) {
 			RTE_LOG(ERR, EAL,
 				"Cannot unregister vaddr for IOMMU, error "
-				"%i (%s)\n", errno, strerror(errno));
+				"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		}
 	}
@@ -1704,7 +1704,7 @@  vfio_spapr_create_dma_window(int vfio_container_fd)
 	ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);
 	if (ret) {
 		RTE_LOG(ERR, EAL, "Cannot get IOMMU info, error %i (%s)\n",
-			errno, strerror(errno));
+			errno, rte_strerror(errno));
 		return -1;
 	}
 
@@ -1745,7 +1745,7 @@  vfio_spapr_create_dma_window(int vfio_container_fd)
 #endif /* VFIO_IOMMU_SPAPR_INFO_DDW */
 	if (ret) {
 		RTE_LOG(ERR, EAL, "Cannot create new DMA window, error "
-				"%i (%s)\n", errno, strerror(errno));
+				"%i (%s)\n", errno, rte_strerror(errno));
 		RTE_LOG(ERR, EAL,
 			"Consider using a larger hugepage size if supported by the system\n");
 		return -1;
@@ -2006,7 +2006,7 @@  rte_vfio_noiommu_is_enabled(void)
 	if (fd < 0) {
 		if (errno != ENOENT) {
 			RTE_LOG(ERR, EAL, "Cannot open VFIO noiommu file "
-					"%i (%s)\n", errno, strerror(errno));
+					"%i (%s)\n", errno, rte_strerror(errno));
 			return -1;
 		}
 		/*
@@ -2020,7 +2020,7 @@  rte_vfio_noiommu_is_enabled(void)
 	close(fd);
 	if (cnt != 1) {
 		RTE_LOG(ERR, EAL, "Unable to read from VFIO noiommu file "
-				"%i (%s)\n", errno, strerror(errno));
+				"%i (%s)\n", errno, rte_strerror(errno));
 		return -1;
 	}
 
diff --git a/lib/eal/unix/eal_filesystem.c b/lib/eal/unix/eal_filesystem.c
index afbab9368a..51b4d513f2 100644
--- a/lib/eal/unix/eal_filesystem.c
+++ b/lib/eal/unix/eal_filesystem.c
@@ -13,6 +13,7 @@ 
 #include <unistd.h>
 
 #include <rte_log.h>
+#include <rte_errno.h>
 
 #include "eal_private.h"
 #include "eal_filesystem.h"
@@ -59,14 +60,14 @@  int eal_create_runtime_dir(void)
 	ret = mkdir(tmp, 0700);
 	if (ret < 0 && errno != EEXIST) {
 		RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
-			tmp, strerror(errno));
+			tmp, rte_strerror(errno));
 		return -1;
 	}
 
 	ret = mkdir(run_dir, 0700);
 	if (ret < 0 && errno != EEXIST) {
 		RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
-			run_dir, strerror(errno));
+			run_dir, rte_strerror(errno));
 		return -1;
 	}
 
diff --git a/lib/eal/unix/eal_unix_memory.c b/lib/eal/unix/eal_unix_memory.c
index 68ae93bd6e..d9652496df 100644
--- a/lib/eal/unix/eal_unix_memory.c
+++ b/lib/eal/unix/eal_unix_memory.c
@@ -32,7 +32,7 @@  mem_map(void *requested_addr, size_t size, int prot, int flags,
 		RTE_LOG(DEBUG, EAL,
 		    "Cannot mmap(%p, 0x%zx, 0x%x, 0x%x, %d, 0x%"PRIx64"): %s\n",
 		    requested_addr, size, prot, flags, fd, offset,
-		    strerror(errno));
+		    rte_strerror(errno));
 		rte_errno = errno;
 		return NULL;
 	}
@@ -45,7 +45,7 @@  mem_unmap(void *virt, size_t size)
 	int ret = munmap(virt, size);
 	if (ret < 0) {
 		RTE_LOG(DEBUG, EAL, "Cannot munmap(%p, 0x%zx): %s\n",
-			virt, size, strerror(errno));
+			virt, size, rte_strerror(errno));
 		rte_errno = errno;
 	}
 	return ret;
@@ -84,7 +84,7 @@  eal_mem_set_dump(void *virt, size_t size, bool dump)
 	int ret = madvise(virt, size, flags);
 	if (ret) {
 		RTE_LOG(DEBUG, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
-				virt, size, flags, strerror(rte_errno));
+				virt, size, flags, rte_strerror(rte_errno));
 		rte_errno = errno;
 	}
 	return ret;
diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c
index 36a21ab2f9..486fd72277 100644
--- a/lib/eal/unix/rte_thread.c
+++ b/lib/eal/unix/rte_thread.c
@@ -302,7 +302,7 @@  rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *))
 	err = pthread_key_create(&((*key)->thread_index), destructor);
 	if (err) {
 		RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n",
-			strerror(err));
+			rte_strerror(err));
 		free(*key);
 		rte_errno = ENOEXEC;
 		return -1;
@@ -323,7 +323,7 @@  rte_thread_key_delete(rte_thread_key key)
 	err = pthread_key_delete(key->thread_index);
 	if (err) {
 		RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n",
-			strerror(err));
+			rte_strerror(err));
 		free(key);
 		rte_errno = ENOEXEC;
 		return -1;
@@ -345,7 +345,7 @@  rte_thread_value_set(rte_thread_key key, const void *value)
 	err = pthread_setspecific(key->thread_index, value);
 	if (err) {
 		RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n",
-			strerror(err));
+			rte_strerror(err));
 		rte_errno = ENOEXEC;
 		return -1;
 	}