* [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
@ 2026-04-30 9:19 Cyril Hrubis
2026-04-30 10:19 ` Andrea Cervesato via ltp
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Cyril Hrubis @ 2026-04-30 9:19 UTC (permalink / raw)
To: ltp
Calling tst_reinit() when library is already initialized or calling it
for a second time is always mistake. With that we silenty drop the old
IPC region, that may have contained test results and there are likely
other problems possibly caused by initializing the test library twice.
To fix that this patch adds tst_brk() that abort the test if we call
tst_reinit() with already initialized test library.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
lib/tst_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 26f6510a0..fa61e1be4 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -196,6 +196,9 @@ void tst_reinit(void)
size_t size = getpagesize();
int fd;
+ if (ipc)
+ tst_brk(TBROK, "Test library already initialized!");
+
if (!path)
tst_brk(TBROK, IPC_ENV_VAR" is not defined");
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-04-30 9:19 [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized Cyril Hrubis
@ 2026-04-30 10:19 ` Andrea Cervesato via ltp
2026-04-30 10:34 ` Li Wang
2026-04-30 11:38 ` [LTP] " linuxtestproject.agent
2 siblings, 0 replies; 11+ messages in thread
From: Andrea Cervesato via ltp @ 2026-04-30 10:19 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-04-30 9:19 [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized Cyril Hrubis
2026-04-30 10:19 ` Andrea Cervesato via ltp
@ 2026-04-30 10:34 ` Li Wang
2026-04-30 12:53 ` Cyril Hrubis
2026-04-30 11:38 ` [LTP] " linuxtestproject.agent
2 siblings, 1 reply; 11+ messages in thread
From: Li Wang @ 2026-04-30 10:34 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
On Thu, Apr 30, 2026 at 11:19:56AM +0200, Cyril Hrubis wrote:
> Calling tst_reinit() when library is already initialized or calling it
> for a second time is always mistake. With that we silenty drop the old
> IPC region, that may have contained test results and there are likely
> other problems possibly caused by initializing the test library twice.
>
> To fix that this patch adds tst_brk() that abort the test if we call
> tst_reinit() with already initialized test library.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Li Wang <li.wang@linux.dev>
The patch itself looks good, I'm just wondering how you found
this issue, was it called twice somewhere/in a test?
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] lib: tst_test: tst_reinit() abort when already initialized
2026-04-30 9:19 [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized Cyril Hrubis
2026-04-30 10:19 ` Andrea Cervesato via ltp
2026-04-30 10:34 ` Li Wang
@ 2026-04-30 11:38 ` linuxtestproject.agent
2 siblings, 0 replies; 11+ messages in thread
From: linuxtestproject.agent @ 2026-04-30 11:38 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp, LTP AI Reviewer
Hi Cyril,
On 2026-04-30, Cyril Hrubis wrote:
> lib: tst_test: tst_reinit() abort when already initialized
> + if (ipc)
> + tst_brk(TBROK, "Test library already initialized!");
Looks good.
Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/25163012944
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-04-30 10:34 ` Li Wang
@ 2026-04-30 12:53 ` Cyril Hrubis
2026-05-07 1:00 ` Li Wang
0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2026-04-30 12:53 UTC (permalink / raw)
To: ltp
Hi!
> > Calling tst_reinit() when library is already initialized or calling it
> > for a second time is always mistake. With that we silenty drop the old
> > IPC region, that may have contained test results and there are likely
> > other problems possibly caused by initializing the test library twice.
> >
> > To fix that this patch adds tst_brk() that abort the test if we call
> > tst_reinit() with already initialized test library.
> >
> > Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
>
> Reviewed-by: Li Wang <li.wang@linux.dev>
>
> The patch itself looks good, I'm just wondering how you found
> this issue, was it called twice somewhere/in a test?
https://lists.linux.it/pipermail/ltp/2026-April/048084.html
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-04-30 12:53 ` Cyril Hrubis
@ 2026-05-07 1:00 ` Li Wang
2026-05-07 6:58 ` Cyril Hrubis
0 siblings, 1 reply; 11+ messages in thread
From: Li Wang @ 2026-05-07 1:00 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Patch merged, thanks!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-05-07 1:00 ` Li Wang
@ 2026-05-07 6:58 ` Cyril Hrubis
2026-05-07 8:41 ` Li Wang
0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2026-05-07 6:58 UTC (permalink / raw)
To: ltp
Hi!
I guess that we also need to revert:
https://lists.linux.it/pipermail/ltp/2026-April/048007.html
Since the IMA test is broken after this patch:
$./ima_mmap -f foo
tst_test.c:2042: TINFO: LTP version: 20260130-210-gcd9899ce4
tst_test.c:2045: TINFO: Tested kernel: 6.16.0 #1 SMP PREEMPT_DYNAMIC Tue Aug 12 10:49:53 CEST 2025 x86_64
tst_kconfig.c:90: TINFO: Parsing kernel config '/lib/modules/6.16.0/build/.config'
tst_test.c:1870: TINFO: Overall timeout per run is 0h 00m 30s
tst_test.c:199: TBROK: Test library already initialized!
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-05-07 6:58 ` Cyril Hrubis
@ 2026-05-07 8:41 ` Li Wang
2026-05-07 9:02 ` Li Wang
0 siblings, 1 reply; 11+ messages in thread
From: Li Wang @ 2026-05-07 8:41 UTC (permalink / raw)
To: Cyril Hrubis, pvorel; +Cc: ltp
Cyril Hrubis wrote:
> I guess that we also need to revert:
>
> https://lists.linux.it/pipermail/ltp/2026-April/048007.html
>
> Since the IMA test is broken after this patch:
You're right, tst_reinit() shouldn't be called in an LTP test with
already initialized the IPC.
Or, we should convert ima_mmap.c into raw main() format proceduer.
> $./ima_mmap -f foo
> tst_test.c:2042: TINFO: LTP version: 20260130-210-gcd9899ce4
> tst_test.c:2045: TINFO: Tested kernel: 6.16.0 #1 SMP PREEMPT_DYNAMIC Tue Aug 12 10:49:53 CEST 2025 x86_64
> tst_kconfig.c:90: TINFO: Parsing kernel config '/lib/modules/6.16.0/build/.config'
> tst_test.c:1870: TINFO: Overall timeout per run is 0h 00m 30s
> tst_test.c:199: TBROK: Test library already initialized!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-05-07 8:41 ` Li Wang
@ 2026-05-07 9:02 ` Li Wang
2026-05-07 9:08 ` Cyril Hrubis
0 siblings, 1 reply; 11+ messages in thread
From: Li Wang @ 2026-05-07 9:02 UTC (permalink / raw)
To: Cyril Hrubis, pvorel, ltp
> > I guess that we also need to revert:
I look into Petr's patch, seems we can go another way to replace
the checkpoint method.
How about this:
--- a/testcases/kernel/security/integrity/ima/src/ima_mmap.c
+++ b/testcases/kernel/security/integrity/ima/src/ima_mmap.c
@@ -34,10 +34,7 @@ static void run(void)
file = SAFE_MMAP(NULL, MMAPSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
SAFE_CLOSE(fd);
- tst_reinit();
- TST_CHECKPOINT_WAIT(0);
- /* keep running until ima_violations.sh open and close file */
- TST_CHECKPOINT_WAKE_AND_WAIT(0);
+ raise(SIGSTOP);
tst_res(TPASS, "test completed");
}
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
index d7dcd077b..e772cf53b 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
@@ -156,6 +156,14 @@ test2()
validate $num_violations $count $search
}
+wait_process_stopped()
+{
+ while true; do
+ [ "$(awk '{print $3}' /proc/$1/stat 2>/dev/null)" = "T" ] && break
+ usleep 100000
+ done
+}
+
test3()
{
local pid
@@ -173,13 +181,13 @@ test3()
ima_mmap -f $FILE &
pid=$!
- # wait for violations appear in logs
- TST_CHECKPOINT_WAKE_AND_WAIT 0
+ wait_process_stopped $pid
open_file_read
close_file_read
- TST_CHECKPOINT_WAKE 0
+ kill -CONT $pid
+ wait $pid
validate $num_violations $count $search
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-05-07 9:02 ` Li Wang
@ 2026-05-07 9:08 ` Cyril Hrubis
2026-05-07 9:13 ` Li Wang
0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2026-05-07 9:08 UTC (permalink / raw)
To: pvorel, ltp
Hi!
> I look into Petr's patch, seems we can go another way to replace
> the checkpoint method.
I would rather change the binary to use TST_NO_DEFAULT_MAIN. It's not a
test, just a helper binary, the tst_test structure shouldn't have been
used to begin with.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized
2026-05-07 9:08 ` Cyril Hrubis
@ 2026-05-07 9:13 ` Li Wang
0 siblings, 0 replies; 11+ messages in thread
From: Li Wang @ 2026-05-07 9:13 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Cyril Hrubis wrote:
> Hi!
> > I look into Petr's patch, seems we can go another way to replace
> > the checkpoint method.
>
> I would rather change the binary to use TST_NO_DEFAULT_MAIN. It's not a
> test, just a helper binary, the tst_test structure shouldn't have been
> used to begin with.
That sounds reasonable! To avoid mixing with real LTP tests,
we should keep the auxiliary binary clean.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-05-07 9:14 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 9:19 [LTP] [PATCH] lib: tst_test: tst_reinit() abort when already initialized Cyril Hrubis
2026-04-30 10:19 ` Andrea Cervesato via ltp
2026-04-30 10:34 ` Li Wang
2026-04-30 12:53 ` Cyril Hrubis
2026-05-07 1:00 ` Li Wang
2026-05-07 6:58 ` Cyril Hrubis
2026-05-07 8:41 ` Li Wang
2026-05-07 9:02 ` Li Wang
2026-05-07 9:08 ` Cyril Hrubis
2026-05-07 9:13 ` Li Wang
2026-04-30 11:38 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox