Skip to contentSkip to conversation

runtest generator prototype for runtest/cve

PATCH In review Cyril Hrubis 3 participants 49 messages Jun 24 – Jul 8 Library code

lore
Share & tools
lore
#0 lore raw

cover runtest generator prototype for runtest/cve

This patchset is mostly preparation for the runtest file generator. We add two more fields to the tst_test structure. Rewrite tests to new libraries etc. But it also fixes bugs in the build system. These patches should go in regardless of the last patch that introduces the runtest file generator.

Once the runtest generator is merged we can easily add more. e.g. syscalls-ipc. However the main point of these changes is to have the complete information on how to filter and run tests in the metadata so that we can add advanced filtering and features to the kirk test runner. Or eventually that people can generate their own runtest files on demand based on the JSON metadata with their own scripts and rules.

Cyril Hrubis (13):
tst_test: Add may_kmemleak flag and annotate tests keyctl01.sh: Rewrite to the new shell library keyctl01.sh: Remove the keyctl subcommand check
tst_run_shell: Add support for groups in the env JSON vma05.sh, keyctl01.sh: Add groups
mem/ksm05: Add proper runtime support mem/thp01: Add proper runtime support
lib: tst_test: Move the iterations to struct tst_test syscalls/setsockopt08: Add .iterations = 100
testcases: Fix the CVE tags
build: rules.mk: Fix HOST_MAKE_TARGET rule
mem: vma03: Rewrite to the new test library
metadata: Add runtest file generator

 include/mk/rules.mk                           |   4 +-
 include/tst_test.h                            |  10 +-
 lib/tst_test.c                                |   8 +-
 metadata/.gitignore                           |   1 +
 metadata/Makefile                             |  10 +-
 metadata/genruntest.c                         | 292 ++++++++++++++++++
 metadata/metaparse.c                          |   1 +
 runtest/.gitignore                            |   1 +
 runtest/cve                                   | 100 ------
 runtest/mm                                    |   4 +-
 testcases/commands/keyctl/keyctl01.sh         |  89 ++----
 testcases/cve/cve-2022-4378.c                 |   1 +
 testcases/cve/cve-2025-21756.c                |   1 +
 testcases/cve/cve-2025-38236.c                |   1 +
 testcases/kernel/containers/userns/userns08.c |   2 +-
 testcases/kernel/crypto/af_alg08.c            |   1 +
 testcases/kernel/mem/ksm/ksm05.c              |  27 +-
 testcases/kernel/mem/thp/thp01.c              |  11 +-
 testcases/kernel/mem/vma/vma03.c              | 189 +++++-------
 testcases/kernel/mem/vma/vma05.sh             |   3 +
 testcases/kernel/pty/pty04.c                  |   2 +-
 .../kernel/security/dirtypipe/dirtypipe.c     |   2 +-
 testcases/kernel/syscalls/bpf/bpf_prog05.c    |   2 +-
 testcases/kernel/syscalls/bpf/bpf_prog06.c    |   2 +-
 testcases/kernel/syscalls/bpf/bpf_prog07.c    |   2 +-
 .../kernel/syscalls/fsconfig/fsconfig03.c     |   1 +
 .../gethostbyname_r/gethostbyname_r01.c       |   2 +-
 .../kernel/syscalls/io_uring/io_uring04.c     |   1 +
 testcases/kernel/syscalls/kill/kill13.c       |   2 +-
 .../perf_event_open/perf_event_open03.c       |   1 +
 .../syscalls/set_mempolicy/set_mempolicy05.c  |   2 +-
 .../kernel/syscalls/setsockopt/setsockopt03.c |   2 +-
 .../kernel/syscalls/setsockopt/setsockopt08.c |   1 +
 testcases/lib/tst_run_shell.c                 |  18 +-
 testcases/network/sockets/vsock01.c           |   2 +-
 testcases/network/sockets/xfrm01.c            |   1 +
 testcases/network/sockets/xfrm02.c            |   1 +
 testcases/network/sockets/xfrm03.c            |   1 +
 38 files changed, 490 insertions(+), 311 deletions(-)
 create mode 100644 metadata/genruntest.c
 create mode 100644 runtest/.gitignore
 delete mode 100644 runtest/cve
 mode change 100644 => 100755 testcases/commands/keyctl/keyctl01.sh
Signature · 5 lines
2.53.0


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

PATCH 1/13 tst_test: Add may_kmemleak flag and annotate tests

This information was so far recoded only in the comment in the cve runtest file. Move it to the test so that it appears in the metadata.

---
 include/tst_test.h                                          | 6 +++++-
 metadata/metaparse.c                                        | 1 +
 testcases/cve/cve-2022-4378.c                               | 1 +
 testcases/cve/cve-2025-21756.c                              | 1 +
 testcases/cve/cve-2025-38236.c                              | 1 +
 testcases/kernel/crypto/af_alg08.c                          | 1 +
 testcases/kernel/syscalls/fsconfig/fsconfig03.c             | 1 +
 testcases/kernel/syscalls/io_uring/io_uring04.c             | 1 +
 .../kernel/syscalls/perf_event_open/perf_event_open03.c     | 1 +
 testcases/network/sockets/xfrm01.c                          | 1 +
 testcases/network/sockets/xfrm02.c                          | 1 +
 testcases/network/sockets/xfrm03.c                          | 1 +
 12 files changed, 16 insertions(+), 1 deletion(-)
include/tst_test.h +5 -1
index c69362485..4afe4cbe0 100644
@@ -353,6 +353,10 @@ struct tst_fs {
  *               needed for tests that need to create device files since tmpfs
  *               at /tmp is usually mounted with 'nodev' option.
  *
+ * @may_kmemleak: If set the test may cause a kernel memory leak. If such test
+ *                fails it's a good idea to reboot before continuing with
+ *                subsequent testcases.
+ *
  * @restore_wallclock: Saves wall clock at the start of the test and restores
  *                     it at the end with the help of monotonic timers.
  *                     Testcases that modify system wallclock use this to
@@ -575,7 +579,7 @@ struct tst_fs {
 	unsigned int skip_in_lockdown:1;
 	unsigned int skip_in_secureboot:1;
 	unsigned int skip_in_compat:1;
-
+	unsigned int may_kmemleak:1;
 
 	int needs_abi_bits;
 
metadata/metaparse.c +1 -0
index a0f94511d..532cbe405 100644
@@ -1141,6 +1141,7 @@ static struct typemap tst_test_typemap[] = {
 	{.id = "needs_hugetlbfs", .type = DATA_BOOL},
 	{.id = "needs_cgroup_nsdelegate", .type = DATA_BOOL},
 	{.id = "needs_cmds", .child = needs_cmds_typemap},
+	{.id = "may_kmemleak", .type = DATA_BOOL},
 	{}
 };
 
testcases/cve/cve-2022-4378.c +1 -0
index 1cb8ea76c..8213d1b20 100644
@@ -86,6 +86,7 @@ static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(testcase_list),
 	.setup = setup,
 	.cleanup = cleanup,
+	.may_kmemleak = 1,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_NS=y",
testcases/cve/cve-2025-21756.c +1 -0
index 80fb84c47..edc6b2aa5 100644
@@ -87,6 +87,7 @@ static void run(void)
 static struct tst_test test = {
 	.test_all = run,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
+	.may_kmemleak = 1,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "fcdd2242c023"},
 		{"CVE", "2025-21756"},
testcases/cve/cve-2025-38236.c +1 -0
index 16582fe64..f6199c06b 100644
@@ -88,6 +88,7 @@ static struct tst_test test = {
 	.test_all = run,
 	.setup = setup,
 	.cleanup = cleanup,
+	.may_kmemleak = 1,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_AF_UNIX_OOB=y",
 		NULL
testcases/kernel/crypto/af_alg08.c +1 -0
index 937ab1758..2de7aba97 100644
@@ -159,6 +159,7 @@ static struct tst_test test = {
 	.test_all = run,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
+	.may_kmemleak = 1,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "a664bf3d603d"},
 		{"CVE", "2026-31431"},
testcases/kernel/syscalls/fsconfig/fsconfig03.c +1 -0
index 43fd4c4a8..68f073836 100644
@@ -88,6 +88,7 @@ static struct tst_test test = {
 	.format_device = 1,
 	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
+	.may_kmemleak = 1,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
 	.skip_filesystems = (const char *const []){"fuse", NULL},
 	.tags = (const struct tst_tag[]) {
testcases/kernel/syscalls/io_uring/io_uring04.c +1 -0
index 026caf334..f3b44749e 100644
@@ -344,6 +344,7 @@ static struct tst_test test = {
 	.timeout = 60,
 	.forks_child = 1,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
+	.may_kmemleak = 1,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_RDS",
 		"CONFIG_RDS_TCP",
testcases/kernel/syscalls/perf_event_open/perf_event_open03.c +1 -0
index 389cc3511..cfd563d81 100644
@@ -127,6 +127,7 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_root = 1,
+	.may_kmemleak = 1,
 	.runtime = 300,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "7bdb157cdebb"},
testcases/network/sockets/xfrm01.c +1 -0
index 2ca77c40f..33905f2a6 100644
@@ -261,6 +261,7 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
+	.may_kmemleak = 1,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_NS=y",
 		"CONFIG_NET_NS=y",
testcases/network/sockets/xfrm02.c +1 -0
index cef9e7060..f99b7b53a 100644
@@ -251,6 +251,7 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
 	.forks_child = 1,
+	.may_kmemleak = 1,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_NS=y",
 		"CONFIG_NET_NS=y",
testcases/network/sockets/xfrm03.c +1 -0
index 676c76e2b..2c83e3ae3 100644
@@ -342,6 +342,7 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
 	.forks_child = 1,
+	.may_kmemleak = 1,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_NS=y",
 		"CONFIG_NET_NS=y",
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 01/13] tst_test: Add may_kmemleak flag and annotate tests

This seems to be one of the first steps towards an "informational" metadata that can be used by the executors, such as kirk or openQA, isn't it?

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 01/13] tst_test: Add may_kmemleak flag and annotate tests

Hi!

Quoted 3 lines

This seems to be one of the first steps towards an "informational" metadata that can be used by the executors, such as kirk or openQA, isn't it?

Indeed. I test with this tag fails the automation should reboot/reload from snapshot before continuing the test.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 2/13 keyctl01.sh: Rewrite to the new shell library

In reply to Cyril Hrubis

No functional changes.

---
 testcases/commands/keyctl/keyctl01.sh | 55 +++++++++++++++------------
 1 file changed, 30 insertions(+), 25 deletions(-)
 mode change 100644 => 100755 testcases/commands/keyctl/keyctl01.sh
testcases/commands/keyctl/keyctl01.sh +30 -25
old mode 100644
new mode 100755
index 7b357a71e..cdbb8bf8b
@@ -2,22 +2,36 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2017 Fujitsu Ltd.
 # Ported: Guangwen Feng <[email protected]>
+# Copyright (c) 2026 Cyril Hrubis <[email protected]>
 #
-# This is a regression test about potential uninitialized variable,
-# the test can crash the buggy kernel, and the bug has been fixed in:
+# ---
+# doc
 #
-#   commit 38327424b40bcebe2de92d07312c89360ac9229a
-#   Author: Dan Carpenter <[email protected]>
-#   Date:   Thu Jun 16 15:48:57 2016 +0100
+# This is a regression test for a potential uninitialized variable in
+# key_reject_and_link(). The test can crash the buggy kernel.
+# ---
 #
-#   KEYS: potential uninitialized variable
+# ---
+# env
+# {
+#  "needs_root": true,
+#  "needs_tmpdir": true,
+#  "needs_cmds": [
+#   {"cmd": "keyctl"}
+#  ],
+#  "save_restore": [
+#   ["/proc/sys/kernel/keys/root_maxbytes", null, "TCONF"]
+#  ],
+#  "tags": [
+#   ["linux-git", "38327424b40bcebe2de92d07312c89360ac9229a"],
+#   ["CVE", "2016-4470"]
+#  ]
+# }
+# ---
+
+. tst_loader.sh
 
 TST_SETUP=setup
-TST_CLEANUP=cleanup
-TST_TESTFUNC=do_test
-TST_NEEDS_ROOT=1
-TST_NEEDS_TMPDIR=1
-TST_NEEDS_CMDS="keyctl"
 
 check_keyctl()
 {
@@ -53,26 +67,18 @@ setup()
 	check_keyctl negate request2 show unlink
 
 	PATH_KEYSTAT="/proc/key-users"
-	PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
 
-	if [ ! -f "$PATH_KEYSTAT" ] || [ ! -f "$PATH_KEYQUOTA" ]; then
-		tst_brk TCONF "'${PATH_KEYSTAT}' or '${PATH_KEYQUOTA}' \
-			does not exist"
+	if [ ! -f "$PATH_KEYSTAT" ]; then
+		tst_brk TCONF "'${PATH_KEYSTAT}' does not exist"
 	fi
 
 	ORIG_KEYSZ=`awk -F' +|/' '/ 0:/ {print $8}' $PATH_KEYSTAT`
-	ORIG_MAXKEYSZ=`cat $PATH_KEYQUOTA`
 }
 
-cleanup()
+tst_test()
 {
-	if [ -n "$ORIG_MAXKEYSZ" ]; then
-		echo $ORIG_MAXKEYSZ >$PATH_KEYQUOTA
-	fi
-}
+	PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
 
-do_test()
-{
 	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
@@ -108,5 +114,4 @@ do_test()
 	tst_res TPASS "Bug not reproduced"
 }
 
-. tst_test.sh
-tst_run
+. tst_run.sh
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 02/13] keyctl01.sh: Rewrite to the new shell library

Hi!
Applied, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] tst_test: Add may_kmemleak flag and annotate tests

In reply to Cyril Hrubis

Hi Cyril,

Quoted 1 line · Cyril Hrubis

tst_test: Add may_kmemleak flag and annotate tests

--- [PATCH 1/13] ---

Quoted 1 line

This information was so far recoded only in the comment in the cve

Typo: "recoded" should be "recorded".

--- [PATCH 8/13] ---

Review

Quoted 4 lines

lib: tst_test: Move the iterations to struct tst_test

(quoted diff) +1 -1
-		iterations = SAFE_STRTOL(optarg, 0, INT_MAX);
+		tst_test->iterations = SAFE_STRTOL(optarg, 0, UINT_MAX);

safe_strtol() takes long min, long max parameters. On 32-bit systems where sizeof(long) == 4, passing UINT_MAX (4294967295U) as a long overflows to -1, making the valid range [0, -1]. This causes the range check to reject all positive values, breaking the -i option on 32-bit.

Should this use INT_MAX (as before) or SAFE_STRTOUL?

--- [PATCH 10/13] ---

Quoted 2 lines

The tags should be in the format year-seq. With the CVE prefix our tolling is broken e.g. tst_test.c prints wrong URLs.

Typo: "tolling" should be "tooling".

--- [PATCH 12/13] ---

Quoted 2 lines

We also drop the __NR_mmap2 ifdef because the lapi/syscalls.h defines the fallbacks to -1 when a syscall is not implemented on an achitecture,

Typo: "achitecture" should be "architecture".

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
#8 lore raw

Re: [LTP] tst_test: Add may_kmemleak flag and annotate tests

Hi!

Quoted 21 lines
Quoted 1 line

tst_test: Add may_kmemleak flag and annotate tests

--- [PATCH 1/13] ---

Quoted 1 line

This information was so far recoded only in the comment in the cve

Typo: "recoded" should be "recorded".

--- [PATCH 8/13] ---

Review

Quoted 4 lines

lib: tst_test: Move the iterations to struct tst_test

(quoted diff) +1 -1
-		iterations = SAFE_STRTOL(optarg, 0, INT_MAX);
+		tst_test->iterations = SAFE_STRTOL(optarg, 0, UINT_MAX);

safe_strtol() takes long min, long max parameters. On 32-bit systems where sizeof(long) == 4, passing UINT_MAX (4294967295U) as a long overflows to -1, making the valid range [0, -1]. This causes the range check to reject all positive values, breaking the -i option on 32-bit.

Quoted 1 line

Should this use INT_MAX (as before) or SAFE_STRTOUL?

Good catch, indeed this should be changed to SAFE_STRTOUL()

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 3/13 keyctl01.sh: Remove the keyctl subcommand check

In reply to Cyril Hrubis

The test was introduced 10 years ago and the functionality is now present on all supported distributions.

---
 testcases/commands/keyctl/keyctl01.sh | 31 ---------------------------
 1 file changed, 31 deletions(-)
testcases/commands/keyctl/keyctl01.sh +0 -31
index cdbb8bf8b..514b6b8bf 100755
@@ -33,39 +33,8 @@
 
 TST_SETUP=setup
 
-check_keyctl()
-{
-	local nosup
-	for op in $@; do
-		nosup=0
-
-		if ! keyctl 2>&1 | grep -q "keyctl $op"; then
-			nosup=1
-		fi
-
-		if [ "$op" = "request2" ]; then
-			local key=`keyctl request2 user debug:foo bar`
-			if [ $? -ne 0 ]; then
-				nosup=1
-			fi
-		fi
-
-		if [ "$op" = "unlink" ]; then
-			if ! keyctl unlink $key @s; then
-				nosup=1
-			fi
-		fi
-
-		if [ $nosup -ne 0 ]; then
-			tst_brk TCONF "keyctl operation $op not supported"
-		fi
-	done
-}
-
 setup()
 {
-	check_keyctl negate request2 show unlink
-
 	PATH_KEYSTAT="/proc/key-users"
 
 	if [ ! -f "$PATH_KEYSTAT" ]; then
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 03/13] keyctl01.sh: Remove the keyctl subcommand check

Hi!
Applied, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 4/13 tst_run_shell: Add support for groups in the env JSON

In reply to Cyril Hrubis

If present we assert that the groups is an array of strings but we don't use the value since it's not used by the test itself. With that we can add groups to the shell tests and they will end up being carried on to the metadata.

---
 testcases/lib/tst_run_shell.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
testcases/lib/tst_run_shell.c +13 -5
index 2778fb6d5..fa893304a 100644
@@ -57,6 +57,7 @@ enum test_attr_ids {
 	DEV_MIN_SIZE,
 	FILESYSTEMS,
 	FORMAT_DEVICE,
+	GROUPS,
 	MIN_CPUS,
 	MIN_MEM_AVAIL,
 	MIN_KVER,
@@ -91,6 +92,7 @@ static ujson_obj_attr test_attrs[] = {
 	UJSON_OBJ_ATTR_IDX(DEV_MIN_SIZE, "dev_min_size", UJSON_INT),
 	UJSON_OBJ_ATTR_IDX(FILESYSTEMS, "filesystems", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(FORMAT_DEVICE, "format_device", UJSON_BOOL),
+	UJSON_OBJ_ATTR_IDX(GROUPS, "groups", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(MIN_CPUS, "min_cpus", UJSON_INT),
 	UJSON_OBJ_ATTR_IDX(MIN_MEM_AVAIL, "min_mem_avail", UJSON_INT),
 	UJSON_OBJ_ATTR_IDX(MIN_KVER, "min_kver", UJSON_STR),
@@ -125,7 +127,7 @@ static ujson_obj test_obj = {
 	.attr_cnt = UJSON_ARRAY_SIZE(test_attrs),
 };
 
-static const char *const *parse_strarr(ujson_reader *reader, ujson_val *val)
+static const char *const *parse_strarr(ujson_reader *reader, ujson_val *val, bool alloc)
 {
 	unsigned int cnt = 0, i = 0;
 	char **ret;
@@ -141,6 +143,9 @@ static const char *const *parse_strarr(ujson_reader *reader, ujson_val *val)
 		cnt++;
 	}
 
+	if (!alloc)
+		return NULL;
+
 	ujson_reader_state_load(reader, state);
 
 	ret = SAFE_MALLOC(sizeof(char *) * (cnt + 1));
@@ -242,7 +247,7 @@ static struct tst_fs *parse_filesystems(ujson_reader *reader, ujson_val *val)
 		UJSON_OBJ_FOREACH_FILTER(reader, val, &fs_obj, ujson_empty_obj) {
 			switch ((enum fs_ids)val->idx) {
 			case MKFS_OPTS:
-				ret[i].mkfs_opts = parse_strarr(reader, val);
+				ret[i].mkfs_opts = parse_strarr(reader, val, true);
 			break;
 			case MKFS_SIZE_OPT:
 				ret[i].mkfs_size_opt = strdup(val->val_str);
@@ -462,6 +467,9 @@ static void parse_metadata(void)
 		case FORMAT_DEVICE:
 			test.format_device = val.val_bool;
 		break;
+		case GROUPS:
+			parse_strarr(&reader, &val, false);
+		break;
 		case MIN_CPUS:
 			if (val.val_int <= 0)
 				ujson_err(&reader, "Minimal number of cpus must be > 0");
@@ -514,7 +522,7 @@ static void parse_metadata(void)
 			test.needs_hugetlbfs = val.val_bool;
 		break;
 		case NEEDS_KCONFIGS:
-			test.needs_kconfigs = parse_strarr(&reader, &val);
+			test.needs_kconfigs = parse_strarr(&reader, &val, true);
 		break;
 		case NEEDS_ROFS:
 			test.needs_rofs = val.val_bool;
@@ -538,7 +546,7 @@ static void parse_metadata(void)
 			test.save_restore = parse_save_restore(&reader, &val);
 		break;
 		case SKIP_FILESYSTEMS:
-			test.skip_filesystems = parse_strarr(&reader, &val);
+			test.skip_filesystems = parse_strarr(&reader, &val, true);
 		break;
 		case SKIP_IN_COMPAT:
 			test.skip_in_compat = val.val_bool;
@@ -550,7 +558,7 @@ static void parse_metadata(void)
 			test.skip_in_secureboot = val.val_bool;
 		break;
 		case SUPPORTED_ARCHS:
-			test.supported_archs = parse_strarr(&reader, &val);
+			test.supported_archs = parse_strarr(&reader, &val, true);
 		break;
 		case TAGS:
 			test.tags = parse_tags(&reader, &val);
Signature · 5 lines
2.53.0


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

PATCH 5/13 vma05.sh, keyctl01.sh: Add groups

In reply to Cyril Hrubis

Unlike the C library the shell metadata parser does not process the JSON, hence the tags are added manually.

Since we have just a few shell tests, automatic group discovery is not worth the effort. If we get more shell tests we will need to rewrite the shell metadata parser to load the JSON into a memory, modify it, and then save it.

---
 testcases/commands/keyctl/keyctl01.sh | 3 +++
 testcases/kernel/mem/vma/vma05.sh     | 3 +++
 2 files changed, 6 insertions(+)
testcases/commands/keyctl/keyctl01.sh +3 -0
index 514b6b8bf..2b2244fae 100755
@@ -22,6 +22,9 @@
 #  "save_restore": [
 #   ["/proc/sys/kernel/keys/root_maxbytes", null, "TCONF"]
 #  ],
+#  "groups": [
+#   "keyctl", "cve", "regression"
+#  ],
 #  "tags": [
 #   ["linux-git", "38327424b40bcebe2de92d07312c89360ac9229a"],
 #   ["CVE", "2016-4470"]
testcases/kernel/mem/vma/vma05.sh +3 -0
index b9654e80c..497abf34f 100755
@@ -34,6 +34,9 @@
 #       "cmd": "uname"
 #     }
 #   ],
+#  "groups": [
+#   "vsyscall", "regression"
+#  ],
 #  "save_restore": [
 #   ["/proc/sys/kernel/core_pattern", "core", "TBROK"],
 #   ["/proc/sys/kernel/core_uses_pid", "0", "TBROK"]
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Hi Cyril,

as I already mentioned, I think we should do this in all tests, instead of having it only for shell tests. I know manual groups are error-prone, but they give us good control over what we are setting up.

I'm not sure if adding groups based on folders as we decided to do it for C API is a good idea. A tst_test->groups array feels better suited, if shell tests can't automatically support the same approach.

We should have the same approach for both C and shell tests to keep consistency.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Hi!

Quoted 9 lines

as I already mentioned, I think we should do this in all tests, instead of having it only for shell tests. I know manual groups are error-prone, but they give us good control over what we are setting up.

I'm not sure if adding groups based on folders as we decided to do it for C API is a good idea. A tst_test->groups array feels better suited, if shell tests can't automatically support the same approach.

I fear that we will have a lot of typos and wrong data in there. We had quite a few wrong CVE tags already, because we weren't checking them for validity.

I'm okay with this as long as we have a checks in 'make check' that make sure that the manually assigned groups are correct. For that we would need the same heuristic we have for automatic groups to check that we didn't miss anything and a list of valid groups to check againts to guard againts typos.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Hi!

Quoted 5 lines

I'm okay with this as long as we have a checks in 'make check' that make sure that the manually assigned groups are correct. For that we would need the same heuristic we have for automatic groups to check that we didn't miss anything and a list of valid groups to check againts to guard againts typos.

And also duplicity check.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

In reply to Cyril Hrubis
Quoted 15 lines

Hi!

Quoted 9 lines

as I already mentioned, I think we should do this in all tests, instead of having it only for shell tests. I know manual groups are error-prone, but they give us good control over what we are setting up.

I'm not sure if adding groups based on folders as we decided to do it for C API is a good idea. A tst_test->groups array feels better suited, if shell tests can't automatically support the same approach.

I fear that we will have a lot of typos and wrong data in there. We had quite a few wrong CVE tags already, because we weren't checking them for validity.

Quoted 5 lines

I'm okay with this as long as we have a checks in 'make check' that make sure that the manually assigned groups are correct. For that we would need the same heuristic we have for automatic groups to check that we didn't miss anything and a list of valid groups to check againts to guard againts typos.

Don't forget we also have the agent that works quite good on these small tasks. We can add a rule and make sure they are always valid groups.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#19 lore raw

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Hi!

Quoted 10 lines
Quoted 9 lines

I fear that we will have a lot of typos and wrong data in there. We had quite a few wrong CVE tags already, because we weren't checking them for validity.

I'm okay with this as long as we have a checks in 'make check' that make sure that the manually assigned groups are correct. For that we would need the same heuristic we have for automatic groups to check that we didn't miss anything and a list of valid groups to check againts to guard againts typos.

Quoted 3 lines

Don't forget we also have the agent that works quite good on these small tasks. We can add a rule and make sure they are always valid groups.

Honestly I'm not 100% convinced that the agent would spot all issues, maybe it would maybe it wouldn't but would you trust it will?

Also linter should be cheaper and pretty easy for this case.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Quoted 1 line

Also linter should be cheaper and pretty easy for this case.

We can easily do that yes, but I don't know where we could implement this inside the make check command. I guess we need one more script verifying the parent folders/test tags and cross-checking with the group name which has been assigned.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Hi!

Quoted 6 lines
Quoted 1 line

Also linter should be cheaper and pretty easy for this case.

We can easily do that yes, but I don't know where we could implement this inside the make check command. I guess we need one more script verifying the parent folders/test tags and cross-checking with the group name which has been assigned.

Or we can write a linter for the metadata. I guess that we can add that to the metaparse tool. We need to check the tags for correctness somewhere as well, otherwise we will get wrongly formatted CVE tags in the future as well.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 05/13] vma05.sh, keyctl01.sh: Add groups

Quoted 8 lines

Hi!

Quoted 6 lines
Quoted 1 line

Also linter should be cheaper and pretty easy for this case.

We can easily do that yes, but I don't know where we could implement this inside the make check command. I guess we need one more script verifying the parent folders/test tags and cross-checking with the group name which has been assigned.

Quoted 8 lines

Or we can write a linter for the metadata. I guess that we can add that to the metaparse tool. We need to check the tags for correctness somewhere as well, otherwise we will get wrongly formatted CVE tags in the future as well.

Signature · 2 lines
Cyril Hrubis
[email protected]

That's a good idea. Let's keep metadata stuff into the metadata folder. I will take a look at this.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#23 lore raw

PATCH 6/13 mem/ksm05: Add proper runtime support

In reply to Cyril Hrubis

The test was executed with -I 10 in all instances. It's cleaner to define the min_runtime in the test and loop the test function until it's exhausted.

One of the bonuses we get from this conversion is that the TPASS message is printed once at the end of the test and we do not flood the logs.

---
 runtest/cve                      |  2 +-
 runtest/mm                       |  2 +-
 testcases/kernel/mem/ksm/ksm05.c | 27 ++++++++++++++++-----------
 3 files changed, 18 insertions(+), 13 deletions(-)
runtest/cve +1 -1
index cc664bb93..789e16aac 100644
@@ -1,6 +1,6 @@
 # Tests which check for vulnerabilities by CVE number
 cve-2011-0999 thp01 -I 120
-cve-2011-2183 ksm05 -I 10
+cve-2011-2183 ksm05
 cve-2011-2496 vma03
 cve-2012-0957 uname04
 cve-2014-0196 cve-2014-0196
runtest/mm +1 -1
index 7d75b65c8..98ec0a4c4 100644
@@ -60,7 +60,7 @@ ksm03 ksm03
 ksm03_1 ksm03 -u 128
 ksm04 ksm04
 ksm04_1 ksm04 -u 128
-ksm05 ksm05 -I 10
+ksm05 ksm05
 ksm06 ksm06
 ksm06_1 ksm06 -n 10
 ksm06_2 ksm06 -n 8000
testcases/kernel/mem/ksm/ksm05.c +16 -11
index 35197914e..0faba54b6 100644
@@ -57,15 +57,6 @@ static void test_ksm(void)
 	long ps;
 	pid_t pid;
 	void *ptr;
-	struct sigaction sa;
-
-	memset (&sa, '\0', sizeof(sa));
-	sa.sa_handler = sighandler;
-	sa.sa_flags = 0;
-	TEST(sigaction(SIGSEGV, &sa, NULL));
-	if (TST_RET == -1)
-		tst_brk(TBROK | TRERRNO,
-				"SIGSEGV signal setup failed");
 
 	ps = sysconf(_SC_PAGESIZE);
 
@@ -80,7 +71,20 @@ static void test_ksm(void)
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
 		tst_brk(TBROK, "invalid signal received: %d", status);
 
-	tst_res(TPASS, "still alive.");
+}
+
+static void run(void)
+{
+	struct sigaction sa = {
+		.sa_handler = sighandler
+	};
+
+	SAFE_SIGACTION(SIGSEGV, &sa, NULL);
+
+	while (tst_remaining_runtime())
+		test_ksm();
+
+	tst_res(TPASS, "Still alive");
 }
 
 static void sighandler(int sig)
@@ -91,7 +95,8 @@ static void sighandler(int sig)
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
-	.test_all = test_ksm,
+	.test_all = run,
+	.min_runtime = 10,
 	.save_restore = (const struct tst_path_val[]) {
 		{PATH_MM_KSM_RUN, "1", TST_SR_TBROK},
 		{PATH_MM_KSM_SMART_SCAN, "0",
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 06/13] mem/ksm05: Add proper runtime support

Hi Cyril,

testcases/kernel/mem/ksm/ksm05.c static void sighandler(int sig) · line 99

Quoted 8 lines

static void sighandler(int sig)

testcases/kernel/mem/ksm/ksm05.c +2 -1
@@ -91,7 +95,8 @@ static void sighandler(int sig)
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
-	.test_all = test_ksm,
+	.test_all = run,
+	.min_runtime = 10,

Even if this is technically correct, I'm not 100% sure about it. Now if we want to manually test the binary, we have to wait 10 seconds by default, while before we had to explicitly use -I.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#25 lore raw

Re: [LTP] [PATCH 06/13] mem/ksm05: Add proper runtime support

Hi!

Quoted 4 lines
Quoted 4 lines

static void sighandler(int sig)

testcases/kernel/mem/ksm/ksm05.c +0 -0
@@ -91,7 +95,8 @@ static void sighandler(int sig)
 static struct tst_test test = {
 	.needs_root = 1,
Quoted 8 lines

testcases/kernel/mem/ksm/ksm05.c static void sighandler(int sig) · line 99

Quoted 4 lines
testcases/kernel/mem/ksm/ksm05.c +2 -1
 	.forks_child = 1,
-	.test_all = test_ksm,
+	.test_all = run,
+	.min_runtime = 10,

Even if this is technically correct, I'm not 100% sure about it. Now if we want to manually test the binary, we have to wait 10 seconds by default, while before we had to explicitly use -I.

I would say that the defaults should be geared towards testing not development. If a test needs 10 seconds to trigger the bug, the default run without any parameters should run for 10 seconds.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 7/13 mem/thp01: Add proper runtime support

In reply to Cyril Hrubis

The test was executed with -I 120 in all instances. It's cleaner to define the min_runtime in the test and loop the test function until it's exhausted.

One of the bonuses we get from this conversion is that the TPASS message is printed once at the end of the test and we do not flood the logs.

---
 runtest/cve                      |  2 +-
 runtest/mm                       |  2 +-
 testcases/kernel/mem/thp/thp01.c | 11 +++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)
runtest/cve +1 -1
index 789e16aac..ca9994868 100644
@@ -1,5 +1,5 @@
 # Tests which check for vulnerabilities by CVE number
-cve-2011-0999 thp01 -I 120
+cve-2011-0999 thp01
 cve-2011-2183 ksm05
 cve-2011-2496 vma03
 cve-2012-0957 uname04
runtest/mm +1 -1
index 98ec0a4c4..c9d460c41 100644
@@ -77,7 +77,7 @@ oom05 oom05
 
 swapping01 swapping01 -i 5
 
-thp01 thp01 -I 120
+thp01 thp01
 thp02 thp02
 thp03 thp03
 thp04 thp04
testcases/kernel/mem/thp/thp01.c +9 -2
index 91c08cb1b..ab34a15fe 100644
@@ -93,8 +93,14 @@ static void thp_test(void)
 		exit(0);
 	}
 	tst_reap_children();
+}
+
+static void run(void)
+{
+	while (tst_remaining_runtime())
+		thp_test();
 
-	tst_res(TPASS, "system didn't crash.");
+	tst_res(TPASS, "System didn't crash");
 }
 
 static void setup(void)
@@ -134,9 +140,10 @@ static void cleanup(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
+	.min_runtime = 120,
 	.setup = setup,
 	.cleanup = cleanup,
-	.test_all = thp_test,
+	.test_all = run,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "a7d6e4ecdb76"},
 		{"CVE", "2011-0999"},
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 07/13] mem/thp01: Add proper runtime support

Hi!
Pushed, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 8/13 lib: tst_test: Move the iterations to struct tst_test

In reply to Cyril Hrubis

This allows us to set the default number of iterations in the tst_test structure.

---
 include/tst_test.h | 4 ++++
 lib/tst_test.c     | 8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
include/tst_test.h +4 -0
index 4afe4cbe0..6befb7787 100644
@@ -478,6 +478,9 @@ struct tst_fs {
  *           probabilistic or fuzzy synchronization tests).
  *           If not set, a default minimum of 1 second is enforced.
  *
+ * @iterations: The default value for the number of test iterations, i.e. the
+ *               -i command line parameter.
+ *
  * @setup: Setup callback is called once at the start of the test in order to
  *         prepare the test environment.
  *
@@ -608,6 +611,7 @@ struct tst_fs {
 	int timeout;
 	int runtime;
 	int min_runtime;
+	unsigned int iterations;
 
 	void (*setup)(void);
 	void (*cleanup)(void);
lib/tst_test.c +5 -3
index 5c3607016..e1166c0c6 100644
@@ -64,7 +64,6 @@ const char *TCID __attribute__((weak));
 struct tst_test *tst_test;
 
 static const char *tcid;
-static int iterations = 1;
 static float duration = -1;
 static float timeout_mul = -1;
 static int reproducible_output;
@@ -834,7 +833,7 @@ static void parse_opts(int argc, char *argv[])
 			print_test_tags();
 			exit(0);
 		case 'i':
-			iterations = SAFE_STRTOL(optarg, 0, INT_MAX);
+			tst_test->iterations = SAFE_STRTOL(optarg, 0, UINT_MAX);
 		break;
 		case 'I':
 			if (tst_test->runtime > 0)
@@ -1484,6 +1483,9 @@ static void do_setup(int argc, char *argv[])
 		}
 	}
 
+	if (tst_test->iterations == 0)
+		tst_test->iterations = 1;
+
 	if (tst_test->mount_device)
 		tst_test->format_device = 1;
 
@@ -1770,7 +1772,7 @@ static void testrun(void)
 	for (;;) {
 		cont = 0;
 
-		if (i < (unsigned int)iterations) {
+		if (i < tst_test->iterations) {
 			i++;
 			cont = 1;
 		}
Signature · 5 lines
2.53.0


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

PATCH 9/13 syscalls/setsockopt08: Add .iterations = 100

In reply to Cyril Hrubis

This moves the number of iterations from the cve runtest file to the actual test. This unifies the test default settings across different runtest files since the number of iterations is now encoded in the test rather than in the runtest file.

The reason I moved the iterations into the test is that if we need 100 iterations to reproducibly trigger the bug it does not make much sense to run only single iteration in the syscalls runtest file.

---
 runtest/cve                                         | 2 +-
 testcases/kernel/syscalls/setsockopt/setsockopt08.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
runtest/cve +1 -1
index ca9994868..5f29d1686 100644
@@ -77,7 +77,7 @@ cve-2021-4034 execve06
 cve-2021-4197_1 cgroup_core01
 cve-2021-4197_2 cgroup_core02
 cve-2021-4204 bpf_prog06
-cve-2021-22555 setsockopt08 -i 100
+cve-2021-22555 setsockopt08
 cve-2021-26708 vsock01
 cve-2021-22600 setsockopt09
 cve-2021-38604 mq_notify03
testcases/kernel/syscalls/setsockopt/setsockopt08.c +1 -0
index 2578638df..5b324cb46 100644
@@ -146,6 +146,7 @@ static struct tst_test test = {
 	.test_all = run,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
 	.forks_child = 1,
+	.iterations = 100,
 	.bufs = (struct tst_buffers []) {
 		{&buffer, .size = 2048},
 		{},
Signature · 5 lines
2.53.0


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

PATCH 10/13 testcases: Fix the CVE tags

In reply to Cyril Hrubis

The tags should be in the format year-seq. With the CVE prefix our tolling is broken e.g. tst_test.c prints wrong URLs.

---
 testcases/kernel/containers/userns/userns08.c                 | 2 +-
 testcases/kernel/pty/pty04.c                                  | 2 +-
 testcases/kernel/security/dirtypipe/dirtypipe.c               | 2 +-
 testcases/kernel/syscalls/bpf/bpf_prog05.c                    | 2 +-
 testcases/kernel/syscalls/bpf/bpf_prog06.c                    | 2 +-
 testcases/kernel/syscalls/bpf/bpf_prog07.c                    | 2 +-
 testcases/kernel/syscalls/gethostbyname_r/gethostbyname_r01.c | 2 +-
 testcases/kernel/syscalls/kill/kill13.c                       | 2 +-
 testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c     | 2 +-
 testcases/kernel/syscalls/setsockopt/setsockopt03.c           | 2 +-
 testcases/network/sockets/vsock01.c                           | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)
testcases/kernel/containers/userns/userns08.c +1 -1
index 2ee4da558..4196bb064 100644
@@ -139,7 +139,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "d2f007dbe7e4"},
-		{"CVE", "CVE-2018-18955"},
+		{"CVE", "2018-18955"},
 		{}
 	},
 };
testcases/kernel/pty/pty04.c +1 -1
index 8bd1bfff5..b23cc0a9d 100644
@@ -494,7 +494,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.tags = (const struct tst_tag[]){
 		{"linux-git", "b9258a2cece4ec1f020715fe3554bc2e360f6264"},
-		{"CVE", "CVE-2020-11494"},
+		{"CVE", "2020-11494"},
 		{}
 	}
 };
testcases/kernel/security/dirtypipe/dirtypipe.c +1 -1
index 981793e64..a1bbe9465 100644
@@ -164,7 +164,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "9d2231c5d74e"},
-		{"CVE", "CVE-2022-0847"},
+		{"CVE", "2022-0847"},
 		{},
 	}
 };
testcases/kernel/syscalls/bpf/bpf_prog05.c +1 -1
index 05cb34e13..6412ca205 100644
@@ -210,7 +210,7 @@ static struct tst_test test = {
 		{"linux-git", "468f6eafa6c4"},
 		{"linux-git", "e88b2c6e5a4d"},
 		{"linux-git", "9b00f1b78809"},
-		{"CVE", "CVE-2021-3444"},
+		{"CVE", "2021-3444"},
 		{}
 	}
 };
testcases/kernel/syscalls/bpf/bpf_prog06.c +1 -1
index f701e9599..830159427 100644
@@ -149,7 +149,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "64620e0a1e71"},
-		{"CVE", "CVE-2021-4204"},
+		{"CVE", "2021-4204"},
 		{}
 	}
 };
testcases/kernel/syscalls/bpf/bpf_prog07.c +1 -1
index e3bf6e7cc..d82f97faf 100644
@@ -153,7 +153,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "64620e0a1e71"},
-		{"CVE", "CVE-2022-23222"},
+		{"CVE", "2022-23222"},
 		{}
 	}
 };
testcases/kernel/syscalls/gethostbyname_r/gethostbyname_r01.c +1 -1
index e4c0cb716..73bf5da99 100644
@@ -56,7 +56,7 @@ static struct tst_test test = {
 	.test_all = check_vulnerable,
 	.tags = (const struct tst_tag[]) {
 		{"glibc-git", "d5dd6189d506"},
-		{"CVE", "CVE-2015-0235"},
+		{"CVE", "2015-0235"},
 		{}
 	}
 };
testcases/kernel/syscalls/kill/kill13.c +1 -1
index ca281ca6c..bf6e4efeb 100644
@@ -37,7 +37,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "4ea77014af0d"},
-		{"CVE", "CVE-2018-10124"},
+		{"CVE", "2018-10124"},
 		{}
 	}
 };
testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c +1 -1
index 65061bf3d..7481dcd8d 100644
@@ -117,7 +117,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "cf01fb9985e8"},
-		{"CVE", "CVE-2017-7616"},
+		{"CVE", "2017-7616"},
 		{}
 	}
 };
testcases/kernel/syscalls/setsockopt/setsockopt03.c +1 -1
index 90d546611..134734acd 100644
@@ -79,7 +79,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.tags = (const struct tst_tag[]){
 		{"linux-git", "ce683e5f9d04"},
-		{"CVE", "CVE-2016-4997"},
+		{"CVE", "2016-4997"},
 		{}
 	}
 };
testcases/network/sockets/vsock01.c +1 -1
index e46f663ed..84c9f9577 100644
@@ -118,7 +118,7 @@ static struct tst_test test = {
 	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "c518adafa39f"},
-		{"CVE", "CVE-2021-26708"},
+		{"CVE", "2021-26708"},
 		{}
 	},
 };
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 10/13] testcases: Fix the CVE tags

Hi!
Applied, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 11/13 build: rules.mk: Fix HOST_MAKE_TARGET rule

In reply to Cyril Hrubis

The rule was written with $< which means that the additional C files were not picked for compilation. Correct it to $^ instead.

---
 include/mk/rules.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/mk/rules.mk +2 -2
index c7da6d37f..2c15c4af1 100644
@@ -35,9 +35,9 @@ endif
 
 $(HOST_MAKE_TARGETS): %: %.c
 ifdef VERBOSE
-	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) $< $(HOST_LDLIBS) -o $@
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) $^ $(HOST_LDLIBS) -o $@
 else
-	@$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) $< $(HOST_LDLIBS) -o $@
+	@$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) $^ $(HOST_LDLIBS) -o $@
 	@echo HOSTCC $(target_rel_dir)$@
 endif
 
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 11/13] build: rules.mk: Fix HOST_MAKE_TARGET rule

Hi!
Applied, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 12/13 mem: vma03: Rewrite to the new test library

In reply to Cyril Hrubis

We also drop the __NR_mmap2 ifdef because the lapi/syscalls.h defines the fallbacks to -1 when a syscall is not implemented on an achitecture, so the macro is always defined.

---
 testcases/kernel/mem/vma/vma03.c | 189 ++++++++++++-------------------
 1 file changed, 73 insertions(+), 116 deletions(-)
testcases/kernel/mem/vma/vma03.c +73 -116
index da1f5be99..7694e7e9a 100644
@@ -1,149 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2026 Cyril Hrubis <[email protected]>
+ */
+
+/*\
+ * CVE-2011-2496 regression test.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Verify that :manpage:`mremap(2)` correctly rejects an expansion that
+ * would cause the page-offset (pgoff) inside the mapping to wrap around
+ * due to overflow.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * The normal :manpage:`mmap(2)` paths all prevent creating a mapping
+ * whose pgoff could wrap, but an expanding :manpage:`mremap(2)` was
+ * able to take a valid mapping and grow it past the wrap boundary.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
+ * The test uses :manpage:`mmap2(2)` to create a file-backed mapping at
+ * a pgoff near ``ULONG_MAX``, then attempts to double its size with
+ * :manpage:`mremap(2)`. The kernel must reject this with ``EINVAL``.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-/*
- * This is a reproducer for CVE-2011-2496.
- *
- * The normal mmap paths all avoid creating a mapping where the pgoff
- * inside the mapping could wrap around due to overflow.  However, an
- * expanding mremap() can take such a non-wrapping mapping and make it
- * bigger and cause a wrapping condition. There is also another case
- * where we expand mappings hiding in plain sight: the automatic stack
- * expansion.
- *
- * This program tries to remap a mapping with a new size that would
- * wrap pgoff. Notice that it only works on 32-bit arch for now.
+ * This test only runs on 32-bit systems with a 32-bit kernel because
+ * the overflow requires a 32-bit ``unsigned long`` address space.
  */
 
 #define _GNU_SOURCE
-#include "config.h"
-#include <sys/types.h>
 #include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <errno.h>
-#include <fcntl.h>
 #include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
 
-#include "test.h"
-#include "tso_safe_macros.h"
-#include "tst_kernel.h"
+#include "tst_test.h"
 #include "lapi/abisize.h"
+#include "lapi/syscalls.h"
 
-char *TCID = "vma03";
-int TST_TOTAL = 1;
-
-#ifdef __NR_mmap2
 #define TESTFILE "testfile"
 
+static int fd = -1;
 static size_t pgsz;
-static int fd;
+static void *map = MAP_FAILED;
 
-static void *mmap2(void *addr, size_t length, int prot,
-		   int flags, int fd, off_t pgoffset);
-static void setup(void);
-static void cleanup(void);
-
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-	void *map, *remap;
-	off_t pgoff;
-
-	if (TST_ABI != 32 || tst_kernel_bits() != 32) {
-		tst_brkm(TCONF, NULL,
-			 "test is designed for 32-bit system only.");
-	}
+	if (TST_ABI != 32 || tst_kernel_bits() != 32)
+		tst_brk(TCONF, "test is designed for 32-bit systems only");
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	pgsz = sysconf(_SC_PAGE_SIZE);
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		fd = SAFE_OPEN(NULL, TESTFILE, O_RDWR);
-
-		/*
-		 * The pgoff is counted in 4K units and must be page-aligned,
-		 * hence we must align it down to page_size/4096 in a case that
-		 * the system has page_size > 4K.
-		 */
-		pgoff = (ULONG_MAX - 1)&(~((pgsz-1)>>12));
-		map = mmap2(NULL, pgsz, PROT_READ | PROT_WRITE, MAP_PRIVATE,
-			    fd, pgoff);
-		if (map == MAP_FAILED)
-			tst_brkm(TBROK | TERRNO, cleanup, "mmap2");
-
-		remap = mremap(map, pgsz, 2 * pgsz, 0);
-		if (remap == MAP_FAILED) {
-			if (errno == EINVAL)
-				tst_resm(TPASS, "mremap failed as expected.");
-			else
-				tst_resm(TFAIL | TERRNO, "mremap");
-			munmap(map, pgsz);
-		} else {
-			tst_resm(TFAIL, "mremap succeeded unexpectedly.");
-			munmap(remap, 2 * pgsz);
-		}
-
-		close(fd);
-	}
+	pgsz = getpagesize();
 
-	cleanup();
-	tst_exit();
+	SAFE_CREAT(TESTFILE, 0644);
 }
 
-static void *mmap2(void *addr, size_t length, int prot,
-		   int flags, int fd, off_t pgoffset)
+static void run(void)
 {
-	return (void *)syscall(SYS_mmap2, addr, length, prot,
-			       flags, fd, pgoffset);
-}
+	/*
+	 * pgoff is counted in 4K units, must be page-aligned, so
+	 * align down to page_size/4096 for systems with page_size > 4K.
+	 */
+	off_t pgoff = (ULONG_MAX - 1) & (~((pgsz - 1) >> 12));
 
-static void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, cleanup);
+	fd = SAFE_OPEN(TESTFILE, O_RDWR);
+
+	map = (void *)tst_syscall(__NR_mmap2, NULL, pgsz,
+				  PROT_READ | PROT_WRITE,
+				  MAP_PRIVATE, fd, pgoff);
+
+	if (map == MAP_FAILED) {
+		tst_brk(TBROK | TERRNO, "mmap2(%s, pgoff=%ld)",
+			TESTFILE, (long)pgoff);
+	}
+
+	void *remap = mremap(map, pgsz, 2 * pgsz, 0);
 
-	tst_tmpdir();
+	if (remap == MAP_FAILED) {
+		if (errno == EINVAL)
+			tst_res(TPASS, "mremap() failed with EINVAL as expected");
+		else
+			tst_res(TFAIL | TERRNO, "mremap() failed unexpectedly");
 
-	fd = SAFE_CREAT(NULL, TESTFILE, 0644);
-	close(fd);
+		SAFE_MUNMAP(map, pgsz);
+	} else {
+		tst_res(TFAIL, "mremap() succeeded unexpectedly");
+		SAFE_MUNMAP(remap, 2 * pgsz);
+	}
 
-	TEST_PAUSE;
+	map = MAP_FAILED;
+	SAFE_CLOSE(fd);
 }
 
 static void cleanup(void)
 {
-	tst_rmdir();
-}
-#else /* __NR_mmap2 */
-int main(int argc, char *argv[])
-{
-	tst_brkm(TCONF, NULL, "__NR_mmap2 is not defined on your system");
+	if (map != MAP_FAILED)
+		SAFE_MUNMAP(map, pgsz);
+
+	if (fd != -1)
+		SAFE_CLOSE(fd);
 }
-#endif
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "982134ba6261"},
+		{"CVE", "2011-2496"},
+		{}
+	}
+};
Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 12/13] mem: vma03: Rewrite to the new test library

Hi!

testcases/kernel/mem/vma/vma03.c line 43

Quoted 2 lines
testcases/kernel/mem/vma/vma03.c +2 -0
+	if (TST_ABI != 32 || tst_kernel_bits() != 32)
+		tst_brk(TCONF, "test is designed for 32-bit systems only");

I would use tst_test->needs_abi_bits, since there's no need to do this check at the beginning of setup().

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#43 lore raw

Re: [LTP] [PATCH 12/13] mem: vma03: Rewrite to the new test library

Hi!

Quoted 5 lines

testcases/kernel/mem/vma/vma03.c line 43

Quoted 2 lines
testcases/kernel/mem/vma/vma03.c +2 -0
+	if (TST_ABI != 32 || tst_kernel_bits() != 32)
+		tst_brk(TCONF, "test is designed for 32-bit systems only");

I would use tst_test->needs_abi_bits, since there's no need to do this check at the beginning of setup().

Ah, right, will do. Do I need to send a V2 or can I commit with this fixed?

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH 13/13 metadata: Add runtest file generator

In reply to Cyril Hrubis

Now just for the runtest/cve file.

The changes in the file are:

- request_key03 is executed once and checks for both CVEs (we have many tests that check for more than one CVE and we execute rest of them once as well)

- if we have more than one test per CVE the suffixes are now numbered (it was random before)

- if test checks for more than one CVE the test tag is the oldest one (the crypto_user01 test jumps up in the runtest file, but again this makes it more consistent)

- kvm CVE tests are included, I do not see a reason to filter them out but we can add that filter if deemed necessary

- the file also includes landlock07 that should have been included but wasn't

---
 metadata/.gitignore   |   1 +
 metadata/Makefile     |  10 +-
 metadata/genruntest.c | 292 ++++++++++++++++++++++++++++++++++++++++++
 runtest/.gitignore    |   1 +
 runtest/cve           | 100 ---------------
 5 files changed, 302 insertions(+), 102 deletions(-)
 create mode 100644 metadata/genruntest.c
 create mode 100644 runtest/.gitignore
 delete mode 100644 runtest/cve
metadata/.gitignore +1 -0
index bb6399e5c..ae33412a6 100644
@@ -1,3 +1,4 @@
 metaparse
 metaparse-sh
+genruntest
 ltp.json
metadata/Makefile +8 -2
index 6939b9f76..fcd63f385 100644
@@ -6,15 +6,21 @@ top_srcdir		?= ..
 include $(top_srcdir)/include/mk/env_pre.mk
 include $(top_srcdir)/include/mk/functions.mk
 
-MAKE_TARGETS		:= ltp.json
-HOST_MAKE_TARGETS	:= metaparse metaparse-sh
+MAKE_TARGETS		:= ltp.json ../runtest/cve
+HOST_MAKE_TARGETS	:= metaparse metaparse-sh genruntest
 INSTALL_DIR		= metadata
 
+genruntest: genruntest.c $(addprefix $(top_srcdir)/libs/ujson/, ujson_reader.c ujson_common.c ujson_utf.c)
+genruntest: HOST_CFLAGS+=-I$(top_srcdir)/include/
+
 .PHONY: ltp.json
 
 ltp.json: metaparse metaparse-sh
 	$(abs_srcdir)/parse.sh > ltp.json
 
+../runtest/cve: ltp.json genruntest
+	${top_builddir}/metadata/genruntest ltp.json cve > ../runtest/cve
+
 test:
 	$(MAKE) -C $(abs_srcdir)/tests/ test
 
metadata/genruntest.c new file +292 -0

292 lines not on this page · raw message

runtest/.gitignore new file +1 -0
new file mode 100644
index 000000000..290696707
@@ -0,0 +1 @@
+cve
runtest/cve deleted +0 -100

100 lines not on this page · raw message

Signature · 5 lines
2.53.0


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

Re: [LTP] [PATCH 13/13] metadata: Add runtest file generator

Hi Cyril,

this is a bit controversial, because we would like to get rid of runtest files. Also, we should start thinking about moving tests variants inside the tst_test struct first, otherwise we will always generate runtest files which re not taking into account tests parameters.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#46 lore raw

Re: [LTP] [PATCH 13/13] metadata: Add runtest file generator

Hi!

Quoted 2 lines

this is a bit controversial, because we would like to get rid of runtest files.

Eventually yes, but we will need this for the transition period. There are a lot of systems out there using runtest files, including openQA. We will have to keep the runtest files for a deprecation period, which will last at least a year or two, before we can drop them. During that period generating the runtest files is in my opinion the best option.

Quoted 3 lines

Also, we should start thinking about moving tests variants inside the tst_test struct first, otherwise we will always generate runtest files which re not taking into account tests parameters.

One step at a time. There are quite a lot of test that does not have any parameters. And quite a few that shouldn't have any parameters. I would say that the -I parameter for CVE reproduces is a hack, because the test is "broken" without any parameters, since the chances it triggers a bug is really small.

There are test where the test variants needs to be encoded in the test structure, these are mostly the I/O stress test where we encode different offsets/sizes in the parameters. But that shouldn't stop us from automating what can be automated already.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 13/13] metadata: Add runtest file generator

In reply to Cyril Hrubis

There's a build issue related to runtest/ folder. It seems like by the time you call genruntest the folder is not present yet.

https://github.com/linux-test-project/ltp/actions/runs/28095394061/job/83183512348

This needs to be fixed in v2.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#48 lore raw

Re: [LTP] [PATCH 13/13] metadata: Add runtest file generator

Hi!

Quoted 6 lines

There's a build issue related to runtest/ folder. It seems like by the time you call genruntest the folder is not present yet.

https://github.com/linux-test-project/ltp/actions/runs/28095394061/job/83183512348

This needs to be fixed in v2.

Sigh, that's the out-of-tree build, we should have dropped that long time ago, since it overcomplicates everything...

Signature · 5 lines
Cyril Hrubis
[email protected]

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