Skip to contentSkip to conversation

fbarray: check file lock downgrade failure

PATCH Superseded Daniil Iskhakov 2 participants 3 messages Sep 29 – Nov 10

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fbarray: check file lock downgrade failure

If unlinking of the file fails, rte_fbarray_destroy() keeps the fbarray mapped and attempts to downgrade the exclusive file lock back to a shared lock. The result of this downgrade is currently ignored.

Check the return value and log a failure. Save errno immediately after the failed unlink(), because subsequent calls may change it. Before returning, set rte_errno to the saved value so the caller receives the primary reason why the destroy operation failed.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas")

---
v2:
- preserve the unlink() error across the lock downgrade attempt
- check the lock operation result explicitly
- update the Fixes tag to the commit that introduced the unchecked downgrade
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 lib/eal/common/eal_common_fbarray.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_fbarray.c +7 -3
index 8bdcefb717..5b3532893c 100644
@@ -1015,15 +1015,19 @@ rte_fbarray_destroy(struct rte_fbarray *arr)
 		/* we're OK to destroy the file */
 		eal_get_fbarray_path(path, sizeof(path), arr->name);
 		if (unlink(path)) {
+			const int unlink_errno = errno;
+
 			EAL_LOG(DEBUG, "Cannot unlink fbarray: %s",
-				strerror(errno));
-			rte_errno = errno;
+				strerror(unlink_errno));
 			/*
 			 * we're still holding an exclusive lock, so drop it to
 			 * shared.
 			 */
-			eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN);
+			if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN) != 0)
+				EAL_LOG(DEBUG, "Cannot restore fbarray shared lock: %s",
+					rte_strerror(rte_errno));
 
+			rte_errno = unlink_errno;
 			ret = -1;
 			goto out;
 		}
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/1 fbarray: check file lock downgrade failure

Hello!
Just a gentle ping regarding the patch. Is there anything I can do to help move its review along?

Best regards,
Daniil

#2 lore raw

Anatoly, this patch is waiting for your review please.

26/10/2026 10:33, Daniil Iskhakov:

Quoted 6 lines

Hello!
Just a gentle ping regarding the patch. Is there anything I can do to help move its review along?

Best regards,
Daniil