Skip to contentSkip to conversation

selftests: livepatch: add test cases of stack_order sysfs

PATCH In review Wardenjohn 4 participants 8 messages Oct 8, 2024 – Oct 11, 2024

Subsystems (2)
lore
Share & tools
lore

Wardenjohn

author
#0 lore raw

cover selftests: livepatch: add test cases of stack_order sysfs

This patch add self test cases to 'stack_order' sysfs interface.

Reuse test module of 'test_klp_livepatch'. However, some module in test_module have '.replace' enable. So, I set the replace value of the stack_order test module to false.

Regards.
Wardenjohn.

author
#1 lore raw

PATCH 1/1 selftests: livepatch: add test cases of stack_order sysfs interface

Add selftest test cases to sysfs attribute 'stack_order'.

---
 .../testing/selftests/livepatch/test-sysfs.sh | 71 +++++++++++++++++++
 .../selftests/livepatch/test_modules/Makefile |  5 +-
 .../test_klp_livepatch_noreplace.c            | 53 ++++++++++++++
 .../test_klp_livepatch_noreplace2.c           | 53 ++++++++++++++
 .../test_klp_livepatch_noreplace3.c           | 53 ++++++++++++++
 5 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace.c
 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace2.c
 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace3.c
tools/testing/selftests/livepatch/test-sysfs.sh +71 -0
index 05a14f5a7bfb..a086b62fb488 100755
@@ -5,6 +5,9 @@
 . $(dirname $0)/functions.sh
 
 MOD_LIVEPATCH=test_klp_livepatch
+MOD_LIVEPATCH_NOREPLACE=test_klp_livepatch_noreplace
+MOD_LIVEPATCH_NOREPLACE2=test_klp_livepatch_noreplace2
+MOD_LIVEPATCH_NOREPLACE3=test_klp_livepatch_noreplace3
 
 setup_config
 
@@ -131,4 +134,72 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
 livepatch: '$MOD_LIVEPATCH': unpatching complete
 % rmmod $MOD_LIVEPATCH"
 
+start_test "sysfs test stack_order read"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r--r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE2
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "-r--r--r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "2"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE3
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r--r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "3"
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE2
+unload_lp $MOD_LIVEPATCH_NOREPLACE2
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r--r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1"
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r--r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "2"
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE3
+unload_lp $MOD_LIVEPATCH_NOREPLACE3
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE
+unload_lp $MOD_LIVEPATCH_NOREPLACE
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': initializing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': completing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': patching complete
+% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE2.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE2'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': patching complete
+% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE3.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE3'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': patching complete
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE2/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE2
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE3/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE3
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE"
+
 exit 0
tools/testing/selftests/livepatch/test_modules/Makefile +4 -1
index e6e638c4bcba..dad6ca00d3e6 100644
@@ -11,7 +11,10 @@ obj-m += test_klp_atomic_replace.o \
 	test_klp_state2.o \
 	test_klp_state3.o \
 	test_klp_shadow_vars.o \
-	test_klp_syscall.o
+	test_klp_syscall.o \
+	test_klp_livepatch_noreplace.o \
+	test_klp_livepatch_noreplace2.o \
+	test_klp_livepatch_noreplace3.o \
 
 # Ensure that KDIR exists, otherwise skip the compilation
 modules:
tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace.c new file +53 -0

53 lines not on this page · raw message

tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace2.c new file +53 -0

53 lines not on this page · raw message

tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_noreplace3.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.43.5
#2 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

Quoted 11 lines · Wardenjohn

Add selftest test cases to sysfs attribute 'stack_order'.

---
 .../testing/selftests/livepatch/test-sysfs.sh | 71
+++++++++++++++++++
 .../selftests/livepatch/test_modules/Makefile |  5 +- .../test_klp_livepatch_noreplace.c            | 53 ++++++++++++++ .../test_klp_livepatch_noreplace2.c           | 53 ++++++++++++++ .../test_klp_livepatch_noreplace3.c           | 53 ++++++++++++++

 5 files changed, 234 insertions(+), 1 deletion(-)
Quoted 9 lines

 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor eplace.c
 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor eplace2.c
 create mode 100644 tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor eplace3.c

IIUC, you only need to test the stack order by loading LP modules. In this case you could use our currently existing LP testing module for that, right? That's what we currently do when testing different sysfs attributes.

Quoted 322 lines
tools/testing/selftests/livepatch/test-sysfs.sh +0 -0
index 05a14f5a7bfb..a086b62fb488 100755
@@ -5,6 +5,9 @@

 . $(dirname $0)/functions.sh

 MOD_LIVEPATCH=test_klp_livepatch

tools/testing/selftests/livepatch/test-sysfs.sh +3 -0
+MOD_LIVEPATCH_NOREPLACE=test_klp_livepatch_noreplace
+MOD_LIVEPATCH_NOREPLACE2=test_klp_livepatch_noreplace2
+MOD_LIVEPATCH_NOREPLACE3=test_klp_livepatch_noreplace3


 setup_config

tools/testing/selftests/livepatch/test-sysfs.sh +0 -0
@@ -131,4 +134,72 @@ livepatch: '$MOD_LIVEPATCH': completing

unpatching transition
 livepatch: '$MOD_LIVEPATCH': unpatching complete
 % rmmod $MOD_LIVEPATCH"

tools/testing/selftests/livepatch/test-sysfs.sh +5 -0
+start_test "sysfs test stack_order read"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r--

r--"

tools/testing/selftests/livepatch/test-sysfs.sh +16 -2
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE2
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "-r--r-
-r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "2"
+
+load_lp $MOD_LIVEPATCH_NOREPLACE3
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r-
-r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "3"
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE2
+unload_lp $MOD_LIVEPATCH_NOREPLACE2
+
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r--

r--"

tools/testing/selftests/livepatch/test-sysfs.sh +13 -1
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1"
+check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r-
-r--"
+check_sysfs_value  "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "2"
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE3
+unload_lp $MOD_LIVEPATCH_NOREPLACE3
+
+disable_lp $MOD_LIVEPATCH_NOREPLACE
+unload_lp $MOD_LIVEPATCH_NOREPLACE
+
+check_result "% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': initializing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +2 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': completing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +4 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': patching complete
+% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE2.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE2'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +2 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +4 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': patching complete
+% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE3.ko
+livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE3'
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +2 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting patching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing patching

transition

tools/testing/selftests/livepatch/test-sysfs.sh +3 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': patching complete
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE2/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing unpatching

transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing unpatching transition

tools/testing/selftests/livepatch/test-sysfs.sh +4 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE2': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE2
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE3/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing unpatching

transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing unpatching transition

tools/testing/selftests/livepatch/test-sysfs.sh +4 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE3': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE3
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE/enabled
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': initializing unpatching

transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': completing unpatching transition

tools/testing/selftests/livepatch/test-sysfs.sh +3 -0
+livepatch: '$MOD_LIVEPATCH_NOREPLACE': unpatching complete
+% rmmod $MOD_LIVEPATCH_NOREPLACE"
+

 exit 0

tools/testing/selftests/livepatch/test_modules/Makefile +4 -1
index e6e638c4bcba..dad6ca00d3e6 100644
@@ -11,7 +11,10 @@ obj-m += test_klp_atomic_replace.o \
  	test_klp_state2.o \
  	test_klp_state3.o \
  	test_klp_shadow_vars.o \
-	test_klp_syscall.o
+	test_klp_syscall.o \
+	test_klp_livepatch_noreplace.o \
+	test_klp_livepatch_noreplace2.o \
+	test_klp_livepatch_noreplace3.o \


 # Ensure that KDIR exists, otherwise skip the compilation modules:
diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace.c b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace.c
new file mode 100644
index 000000000000..ead609aeac67
--- /dev/null
+++
b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace.c

tools/testing/selftests/livepatch/test_modules/Makefile +53 -0
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2014 Seth Jennings <[email protected]>
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/livepatch.h>
+
+#include <linux/seq_file.h>
+static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "%s: %s\n", THIS_MODULE->name,
+		   "this has been live patched with number 1");
+	return 0;
+}
+
+static struct klp_func funcs[] = {
+	{
+		.old_name = "cmdline_proc_show",
+		.new_func = livepatch_cmdline_proc_show,
+	}, { }
+};
+
+static struct klp_object objs[] = {
+	{
+		/* name being NULL means vmlinux */
+		.funcs = funcs,
+	}, { }
+};
+
+static struct klp_patch patch = {
+	.mod = THIS_MODULE,
+	.objs = objs,
+	.replace = false,
+};
+
+static int test_klp_livepatch_init(void)
+{
+	return klp_enable_patch(&patch);
+}
+
+static void test_klp_livepatch_exit(void)
+{
+}
+
+module_init(test_klp_livepatch_init);
+module_exit(test_klp_livepatch_exit);
+MODULE_LICENSE("GPL");
+MODULE_INFO(livepatch, "Y");
+MODULE_AUTHOR("Seth Jennings <[email protected]>");
+MODULE_AUTHOR("Wardenjohn <[email protected]>");
+MODULE_DESCRIPTION("Livepatch test: livepatch module");

diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace2.c b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace2.c
new file mode 100644
index 000000000000..8d54b0976be1
--- /dev/null
+++
b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace2.c

tools/testing/selftests/livepatch/test_modules/Makefile +53 -0
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2014 Seth Jennings <[email protected]>
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/livepatch.h>
+
+#include <linux/seq_file.h>
+static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "%s: %s\n", THIS_MODULE->name,
+		   "this has been live patched with number 2");
+	return 0;
+}
+
+static struct klp_func funcs[] = {
+	{
+		.old_name = "cmdline_proc_show",
+		.new_func = livepatch_cmdline_proc_show,
+	}, { }
+};
+
+static struct klp_object objs[] = {
+	{
+		/* name being NULL means vmlinux */
+		.funcs = funcs,
+	}, { }
+};
+
+static struct klp_patch patch = {
+	.mod = THIS_MODULE,
+	.objs = objs,
+	.replace = false,
+};
+
+static int test_klp_livepatch_init(void)
+{
+	return klp_enable_patch(&patch);
+}
+
+static void test_klp_livepatch_exit(void)
+{
+}
+
+module_init(test_klp_livepatch_init);
+module_exit(test_klp_livepatch_exit);
+MODULE_LICENSE("GPL");
+MODULE_INFO(livepatch, "Y");
+MODULE_AUTHOR("Seth Jennings <[email protected]>");
+MODULE_AUTHOR("Wardenjohn <[email protected]>");
+MODULE_DESCRIPTION("Livepatch test: livepatch module");

diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace3.c b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace3.c
new file mode 100644
index 000000000000..a267c58e07d4
--- /dev/null
+++
b/tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_n oreplace3.c

tools/testing/selftests/livepatch/test_modules/Makefile +53 -0
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2014 Seth Jennings <[email protected]>
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/livepatch.h>
+
+#include <linux/seq_file.h>
+static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "%s: %s\n", THIS_MODULE->name,
+		   "this has been live patched with number 3");
+	return 0;
+}
+
+static struct klp_func funcs[] = {
+	{
+		.old_name = "cmdline_proc_show",
+		.new_func = livepatch_cmdline_proc_show,
+	}, { }
+};
+
+static struct klp_object objs[] = {
+	{
+		/* name being NULL means vmlinux */
+		.funcs = funcs,
+	}, { }
+};
+
+static struct klp_patch patch = {
+	.mod = THIS_MODULE,
+	.objs = objs,
+	.replace = false,
+};
+
+static int test_klp_livepatch_init(void)
+{
+	return klp_enable_patch(&patch);
+}
+
+static void test_klp_livepatch_exit(void)
+{
+}
+
+module_init(test_klp_livepatch_init);
+module_exit(test_klp_livepatch_exit);
+MODULE_LICENSE("GPL");
+MODULE_INFO(livepatch, "Y");
+MODULE_AUTHOR("Seth Jennings <[email protected]>");
+MODULE_AUTHOR("Wardenjohn <[email protected]>");
+MODULE_DESCRIPTION("Livepatch test: livepatch module");
#3 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

Hi, Marcos!

Quoted 24 lines · Marcos Paulo de Souza
Quoted 18 lines · Wardenjohn

Add selftest test cases to sysfs attribute 'stack_order'.

---
 .../testing/selftests/livepatch/test-sysfs.sh | 71
+++++++++++++++++++
 .../selftests/livepatch/test_modules/Makefile |  5 +-
 .../test_klp_livepatch_noreplace.c            | 53 ++++++++++++++
 .../test_klp_livepatch_noreplace2.c           | 53 ++++++++++++++
 .../test_klp_livepatch_noreplace3.c           | 53 ++++++++++++++
 5 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644
tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor
eplace.c
 create mode 100644
tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor
eplace2.c
 create mode 100644
Quoted 2 lines

tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor eplace3.c

Quoted 5 lines

IIUC, you only need to test the stack order by loading LP modules. In this case you could use our currently existing LP testing module for that, right? That's what we currently do when testing different sysfs attributes.

Yes, in fact, those three module I submitted is reuse the existing LP testing module of 'test_klp_livepatch'. Because I found some module in test module set "klp_replace" attribute true. If a module set this attribute true, it will disable the previous module.

What's more, testing this 'stack_order' attribute need more than one module, hoping to change the same function. And breaking the '.replace' value of existing module may not be a good way. So I decided to copy more test module with '.replace=false' and this module is changing the same function.

Regards.
Wardenjohn.

maintainer
#4 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

Quoted 11 lines · zhang warden
Quoted 5 lines

IIUC, you only need to test the stack order by loading LP modules. In this case you could use our currently existing LP testing module for that, right? That's what we currently do when testing different sysfs attributes.

Yes, in fact, those three module I submitted is reuse the existing LP testing module of 'test_klp_livepatch'. Because I found some module in test module set "klp_replace" attribute true. If a module set this attribute true, it will disable the previous module.

Quoted 5 lines

What's more, testing this 'stack_order' attribute need more than one module, hoping to change the same function. And breaking the '.replace' value of existing module may not be a good way. So I decided to copy more test module with '.replace=false' and this module is changing the same function.

Maybe add a replace=[true|false] module parameter.

Signature · 1 line
Josh
#5 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

Quoted 6 lines · Josh Poimboeuf

Maybe add a replace=[true|false] module parameter.

How to do it?
Isn't the way we build modules using make?
How to set this replace value?

Regards
Wardenjohn

maintainer
#6 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

Quoted 10 lines · zhang warden
Quoted 6 lines · Josh Poimboeuf

Maybe add a replace=[true|false] module parameter.

How to do it?
Isn't the way we build modules using make?
How to set this replace value?

See for example what

tools/testing/selftests/livepatch/test_modules/test_klp_atomic_replace.c

is already doing with its "replace" parameter. Just add replace=0 to the insmod args to disable replace mode.

Signature · 1 line
Josh
maintainer
#7 lore raw

Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface

In reply to zhang warden
Quoted 10 lines · zhang warden
Quoted 6 lines · Josh Poimboeuf

Maybe add a replace=[true|false] module parameter.

How to do it?
Isn't the way we build modules using make?
How to set this replace value?

You could find inspiration in tools/testing/selftests/livepatch/test-livepatch.sh, see

load_lp $MOD_REPLACE replace=0

vs.

load_lp $MOD_REPLACE replace=1

You could more or less copy the "multiple livepatches" and "atomic replace livepatch" self-tests. The new tests would check the "stack_order" sysfs value instread of checking whether /proc/cmdline and /proc/meminfo are livepatched.

Best Regards,
Petr