[LTP] test macros: Fix TST_EXP_FD_OR_FAIL()

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Tue Aug 11 18:05:55 CEST 2026


Hi Petr,

On Tue, 11 Aug 2026, Petr Vorel wrote:
> test macros: Fix TST_EXP_FD_OR_FAIL()

--- [PATCH 3/4] ---

> +	TST_EXP_PASS_OR_FAIL(finit_module(fd, "status=valid", 0), err);
>  	if (!TST_PASS)
>  		return;

Could this return when err is nonzero as well?  An expected EKEYREJECTED
sets TST_PASS, so the signature-enforcement path continues to
tst_module_unload() even though the module was never loaded.  The rmmod
retries then end the test with TBROK.  The same issue is present in
init_module01.c.

> +	TST_EXP_FD_OR_FAIL(fd = open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);
> +	if (fd != -1) {
> +		TST_EXP_PASS_OR_FAIL(ftruncate(fd, 10), exp_err);
> +		SAFE_CLOSE(fd);
>  	}
> +
> +	TST_EXP_FD_OR_FAIL(fd = open(FILE_TRUNCATE, O_WRONLY | O_TRUNC, PERM_MODE), exp_err);

Could the first open keep O_WRONLY without O_TRUNC?  In the
LANDLOCK_ACCESS_FS_WRITE_FILE-only variant, O_TRUNC is denied, fd remains
-1, and the ftruncate() check is skipped.  The next identical open then
tests O_TRUNC twice.

--- [PATCH 4/4] ---

> diff --git a/lib/newlib_tests/test_macros04.c b/lib/newlib_tests/test_macros04.c
> deleted file mode 100644

Could the test_macros04 entry be removed from lib/newlib_tests/.gitignore
along with the deleted test?

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list