[LTP] [PATCH v1] Regression check for unlink fail issue after successful mknod

Wei Gao wegao@suse.com
Tue Aug 15 01:26:43 CEST 2023


Write a regression test once making unix_bind() undo mknod on failure patchset is merged.

Kernel patch detail:
git describe --contains c0c3b8d380a8f54c75786d41f6f9efbe761dac6c
v5.14-rc1119^286
git log -p c0c3b8d380a8f54c75786d41f6f9efbe761dac6c
commit c0c3b8d380a8f54c75786d41f6f9efbe761dac6c
Author: Al Viro viro@zeniv.linux.org.uk
Date: Sat Jun 19 03:50:32 2021 +0000
unix_bind_bsd(): unlink if we fail after successful mknod

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/bind/bind03.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/bind/bind03.c b/testcases/kernel/syscalls/bind/bind03.c
index 37a040b29..12285acb9 100644
--- a/testcases/kernel/syscalls/bind/bind03.c
+++ b/testcases/kernel/syscalls/bind/bind03.c
@@ -43,8 +43,13 @@ static void run(void)
 	 * locks the socket and does all the checks and the node is not removed
 	 * in the error path. For now we will unlink the node here so that the
 	 * test works fine when the run() function is executed in a loop.
+	 * From v5.14-rc1 the kernel has fix above issue.
 	 */
-	unlink(SNAME_B);
+	if (tst_kvercmp(5, 14, 0) >= 0) {
+		TST_EXP_FAIL(unlink(SNAME_B), ENOENT,"check exist of SNAME_B");
+	} else {
+		unlink(SNAME_B);
+	}
 }
 
 static void setup(void)
-- 
2.35.3



More information about the ltp mailing list