lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260108090606.20660-2-po-hsu.lin@canonical.com>
Date: Thu,  8 Jan 2026 17:06:06 +0800
From: Po-Hsu Lin <po-hsu.lin@...onical.com>
To: linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: po-hsu.lin@...onical.com,
	shuah@...nel.org,
	mike.kravetz@...cle.com
Subject: [PATCH 1/1] selftests/memfd: fix return value override issue in run_hugetlbfs_test.sh

If the clean up task in the end of this script has successed, this
test will be considered as passed regardless the sub tests results.

$ sudo ./run_hugetlbfs_test.sh
memfd-hugetlb: CREATE
memfd-hugetlb: BASIC
memfd-hugetlb: SEAL-EXEC
memfd-hugetlb:  Apply SEAL_EXEC
fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected
./run_hugetlbfs_test.sh: line 60: 16833 Aborted                 (core dumped) ./memfd_test hugetlbfs
opening: ./mnt/memfd
ADD_SEALS(4, 0 -> 8) failed: Device or resource busy
8 != 0 = GET_SEALS(4)
Aborted (core dumped)
$ echo $?
0

Fix this by checking the return value of each sub-test.

With this patch, the return value of this test will be reflected
correctly and we can avoid a false-negative result:
$ sudo ./run_hugetlbfs_test.sh
memfd-hugetlb: CREATE
memfd-hugetlb: BASIC
memfd-hugetlb: SEAL-EXEC
memfd-hugetlb:	Apply SEAL_EXEC
fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected
./run_hugetlbfs_test.sh: line 68: 16688 Aborted                 (core dumped) ./memfd_test hugetlbfs
opening: ./mnt/memfd
ADD_SEALS(4, 0 -> 8) failed: Device or resource busy
8 != 0 = GET_SEALS(4)
Aborted (core dumped)
$ echo $?
134

Fixes: 8eecdd4d04 ("selftests: memfd: split regular and hugetlbfs tests")
Cc: stable@...r.kernel.org
Signed-off-by: Po-Hsu Lin <po-hsu.lin@...onical.com>
---
 tools/testing/selftests/memfd/run_hugetlbfs_test.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
index fb633eeb0290..48f701983604 100755
--- a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
+++ b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
@@ -4,12 +4,21 @@
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
+ret=0
 #
 # To test memfd_create with hugetlbfs, there needs to be hpages_test
 # huge pages free.  Attempt to allocate enough pages to test.
 #
 hpages_test=8
 
+# set global exit status, but never reset nonzero one.
+check_err()
+{
+	if [ $ret -eq 0 ]; then
+		ret=$1
+	fi
+}
+
 #
 # Get count of free huge pages from /proc/meminfo
 #
@@ -58,7 +67,9 @@ fi
 # Run the hugetlbfs test
 #
 ./memfd_test hugetlbfs
+check_err $?
 ./run_fuse_test.sh hugetlbfs
+check_err $?
 
 #
 # Give back any huge pages allocated for the test
@@ -66,3 +77,4 @@ fi
 if [ -n "$nr_hugepgs" ]; then
 	echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
 fi
+exit $ret
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ