Skip to contentSkip to conversation

Migrating the libhugetlbfs/testcases/truncate_sigbus_versus_oom.c test

PATCH Superseded Samir Mulani 2 participants 2 messages Sep 29, 2025 – Feb 17

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Migrating the libhugetlbfs/testcases/truncate_sigbus_versus_oom.c test

In this test case, we are verifying the bug fix commit that is attached as a part of the test case structure,

Some kernel have a bug in the positioning of the test against i_size. This bug means that attempting to instantiate a page beyond the end of a hugepage file can result in an OOM and SIGKILL instead of the correct SIGBUS.

---
v4: Addressed the below requested changes
1. Dropped the test name from discription.
2. Removed unused macro.
3. Simplified logic by removing redundant sigbus_count and relying solely on test_pass flag set in the signal handler.

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap37.c  | 94 +++++++++++++++++++
 3 files changed, 96 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c
runtest/hugetlb +1 -0
index 0896d3c94..8aaafeee3 100644
@@ -36,6 +36,7 @@ hugemmap30 hugemmap30
 hugemmap31 hugemmap31
 hugemmap32 hugemmap32
 hugemmap34 hugemmap34
+hugemmap37 hugemmap37
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index b4455de51..38d428fe8 100644
@@ -36,6 +36,7 @@
 /hugetlb/hugemmap/hugemmap31
 /hugetlb/hugemmap/hugemmap32
 /hugetlb/hugemmap/hugemmap34
+/hugetlb/hugemmap/hugemmap37
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +94 -0

94 lines not on this page · raw message

Signature · 5 lines
2.47.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 4 lines · Samir Mulani

In this test case, we are verifying the bug fix commit that is attached as a part of the test case structure,

Some kernel have a bug in the positioning of the test against

         ^
	 typo: kernels

testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c line 7

Quoted 9 lines

+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c

testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +7 -0
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2005-2006 David Gibson & Adam Litke, IBM Corporation.
+ */
+
+/*\
+ * [Description]

Description is not needed anymore.

testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c line 9

Quoted 2 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +2 -0
+ *
+ * Some kernel have a bug in the positioning of the test against
            ^
	    typo: kernels
Quoted 5 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +5 -0
+ * i_size.  This bug means that attempting to instantiate a page
+ * beyond the end of a hugepage file can result in an OOM and SIGKILL
+ * instead of the correct SIGBUS.
+ */
+

testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c line 24

Quoted 10 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +10 -0
+#include "hugetlb.h"
+#include <setjmp.h>
+#include <signal.h>
+
+#define MNTPOINT "hugetlbfs/"
+static int fd = -1, fdx = -1;
+
+static unsigned long long hpage_size;
+static unsigned long totpages;
+struct sigaction sa;

Should be used inside the setup().

testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c line 27

Quoted 3 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap37.c new file +3 -0
+static sigjmp_buf sig_escape;
+static volatile int test_pass;
+static int sigbus_count;

Never used.

Signature · 7 lines
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]


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