All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avinesh Kumar via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] landlock04: Fix false TFAIL in _test_truncate() deny path
Date: Mon, 24 Aug 2026 12:15:24 +0200	[thread overview]
Message-ID: <20260824101525.176017-1-avinesh.kumar@suse.com> (raw)

From: Avinesh Kumar <avinesh.kumar@suse.com>

commit 8643b01a68cf converted an intentionally-unchecked open() call
(used only to get an fd for the ftruncate() sub-test) into
TST_EXP_FD_OR_FAIL(), wrongly asserting it must fail with EACCES on
the deny path. Its outcome depends on other granted rights and isn't
guaranteed, causing a false TFAIL when it succeeded.

landlock_tester.h:257: TFAIL: open(FILE_TRUNCATE, O_WRONLY, PERM_MODE) invalid retval 4: SUCCESS (0)

Restore the unchecked open() on the deny path, keep SAFE_OPEN() on the
pass path. Also fix SAFE_CLOSE(TST_RET) to SAFE_CLOSE(fd) for consistency.

Fixes: 8643b01a68cf ("tree: Use TST_EXP_PASS_OR_FAIL() and TST_EXP_FD_OR_FAIL()")
Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com>
---
 testcases/kernel/syscalls/landlock/landlock_tester.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/landlock/landlock_tester.h b/testcases/kernel/syscalls/landlock/landlock_tester.h
index f44721245144..e93f970d87c3 100644
--- a/testcases/kernel/syscalls/landlock/landlock_tester.h
+++ b/testcases/kernel/syscalls/landlock/landlock_tester.h
@@ -254,7 +254,8 @@ static void _test_truncate(const int exp_err)
 	tst_res(TINFO, "Test truncating file");
 
 	TST_EXP_PASS_OR_FAIL(truncate(FILE_TRUNCATE, 10), exp_err);
-	fd = TST_EXP_FD_OR_FAIL(open(FILE_TRUNCATE, O_WRONLY, PERM_MODE), exp_err);
+	fd = exp_err ? open(FILE_TRUNCATE, O_WRONLY, PERM_MODE)
+		     : SAFE_OPEN(FILE_TRUNCATE, O_WRONLY, PERM_MODE);
 	if (fd != -1) {
 		TST_EXP_PASS_OR_FAIL(ftruncate(fd, 10), exp_err);
 		SAFE_CLOSE(fd);
@@ -262,7 +263,7 @@ static void _test_truncate(const int exp_err)
 
 	fd = TST_EXP_FD_OR_FAIL(open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);
 	if (fd != -1)
-		SAFE_CLOSE(TST_RET);
+		SAFE_CLOSE(fd);
 }
 
 static void tester_run_fs_rules(const int rules, const int result)
-- 
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2026-08-24 10:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 10:15 Avinesh Kumar via ltp [this message]
2026-08-24 10:38 ` [LTP] landlock04: Fix false TFAIL in _test_truncate() deny path linuxtestproject.agent
2026-08-24 13:57   ` [LTP] [PATCH v2] " Avinesh Kumar via ltp
2026-08-24 14:04     ` Andrea Cervesato via ltp
2026-08-24 14:42     ` [LTP] " linuxtestproject.agent
2026-08-25  4:38     ` [LTP] [PATCH v2] " Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260824101525.176017-1-avinesh.kumar@suse.com \
    --to=ltp@lists.linux.it \
    --cc=avinesh.kumar@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.