hugemmap36: Migrating the libhugetlbfs/testcases/truncate_above_4GB.c test v6
PATCH 1/1 hugemmap36: Migrating the libhugetlbfs/testcases/truncate_above_4GB.c test v6
Test for a bug where truncating hugepage files at offsets >= 4GB on 32-bit systems could incorrectly truncate lower pages due to a misconversion of hugetlb_vmtruncate_list to a prio_tree. This test verifies that:
- Pages below 4GB remain accessible after truncation at 4GB
- Pages at or above the truncation point correctly trigger SIGBUS
--- runtest/hugetlb | 1 + testcases/kernel/mem/.gitignore | 1 + .../kernel/mem/hugetlb/hugemmap/hugemmap36.c | 153 ++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c
runtest/hugetlb +1 -0
@@ -36,6 +36,7 @@ hugemmap30 hugemmap30 hugemmap31 hugemmap31 hugemmap32 hugemmap32 hugemmap34 hugemmap34 +hugemmap36 hugemmap36 hugemmap05_1 hugemmap05 -m hugemmap05_2 hugemmap05 -s hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
@@ -36,6 +36,7 @@ /hugetlb/hugemmap/hugemmap31 /hugetlb/hugemmap/hugemmap32 /hugetlb/hugemmap/hugemmap34 +/hugetlb/hugemmap/hugemmap36 /hugetlb/hugeshmat/hugeshmat01 /hugetlb/hugeshmat/hugeshmat02 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +153 -0
153 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Pavithra,
Quoted 1 line · Pavithra
hugemmap36: Migrating the
libhugetlbfs/testcases/truncate_above_4GB.ctest v6
The "v6" revision tag belongs in the email subject only, not in the committed subject line. The subject should also use imperative mood:
hugemmap36: Migrate the libhugetlbfs/testcases/truncate_above_4GB.c test
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 41
Quoted 6 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +6
-0+static void sigbus_handler_fail(int signum LTP_ATTRIBUTE_UNUSED, + siginfo_t *si LTP_ATTRIBUTE_UNUSED, + void *uc LTP_ATTRIBUTE_UNUSED) +{ +siglongjmp (sig_escape,17 ); +}
This handler does not record the unexpected SIGBUS in any way. The caller uses it here:
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 111
Quoted 6 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +6
-0+SAFE_SIGACTION (SIGBUS , &sa_fail,NULL ); +if (sigsetjmp (sig_escape,1 ) ==0 ) +if (*pi !=1 ) { +tst_res (TFAIL ,"Data 1 has changed!" ); + goto cleanup; + }
If SIGBUS fires on *pi - which is exactly the kernel bug being tested (the low-offset page was incorrectly truncated) - siglongjmp returns 17, so sigsetjmp(...) == 0 is false, the TFAIL block is skipped entirely, and execution falls through.
The code then reaches the sa_pass / *qi block, *qi triggers SIGBUS, test_pass is set to 1, and the test reports TPASS. The test passes when the kernel bug is present.
sigbus_handler_fail needs to set a flag (e.g. test_pass = -1) so that after the first sigsetjmp block the caller can detect the unexpected SIGBUS and report TFAIL before proceeding.
Quoted 3 lines
+ * Test for a bug where truncating hugepage files at offsets >= 4GB on
+ * 32-bit systems could incorrectly truncate lower pages due to a
+ * misconversion ofhugetlb_vmtruncate_listto aprio_tree.
...
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 146
Quoted 1 line
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +1
-0+ .needs_root = 1,
The doc-comment block does not explain why root is required. Ground Rule 4 requires that the reason be stated there.
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp