All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] lib: Cache kernel_bits value
@ 2021-11-15 15:20 Richard Palethorpe via ltp
  2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
  2021-11-15 16:01 ` [LTP] [PATCH 1/2] lib: Cache kernel_bits value Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Palethorpe via ltp @ 2021-11-15 15:20 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

This is primarily to avoid printing the uname info two or more
times. Which is increasingly likely with using tst_kernel_bits in
other library functions. Also with features like test variants where
setup may be run multiple times.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 lib/tst_kernel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index c908bb04c..6db85bff0 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -37,7 +37,12 @@ static int get_kernel_bits_from_uname(struct utsname *buf)
 int tst_kernel_bits(void)
 {
 	struct utsname buf;
-	int kernel_bits = get_kernel_bits_from_uname(&buf);
+	static int kernel_bits;
+
+	if (kernel_bits)
+		return kernel_bits;
+
+	kernel_bits = get_kernel_bits_from_uname(&buf);
 
 	if (kernel_bits == -1)
 		return -1;
-- 
2.33.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag
  2021-11-15 15:20 [LTP] [PATCH 1/2] lib: Cache kernel_bits value Richard Palethorpe via ltp
@ 2021-11-15 15:20 ` Richard Palethorpe via ltp
  2021-11-15 16:07   ` Cyril Hrubis
  2021-11-15 16:01 ` [LTP] [PATCH 1/2] lib: Cache kernel_bits value Cyril Hrubis
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Palethorpe via ltp @ 2021-11-15 15:20 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Some tests can never be run under 32-bit compatibility mode. This adds
a flag to skip them. This will show up in the meta data in addition to
causing the test to exit with TCONF if compat mode is detected at
runtime.

It's possible that support for compat mode will be added to
CAN. If this happens then we will have to probe the interface for
support when in 32-bit compat mode.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_test.h                          |  1 +
 lib/tst_test.c                              |  4 ++++
 testcases/kernel/syscalls/ptrace/ptrace08.c | 13 +++++--------
 testcases/network/can/cve/can_bcm01.c       |  5 +++++
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/tst_test.h b/include/tst_test.h
index 3dcb45de0..602ce3090 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -164,6 +164,7 @@ struct tst_test {
 	 */
 	int all_filesystems:1;
 	int skip_in_lockdown:1;
+	int skip_in_compat:1;
 
 	/*
 	 * The skip_filesystem is a NULL terminated list of filesystems the
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 02ae28335..c1fab3b18 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -18,6 +18,7 @@
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_device.h"
+#include "lapi/abisize.h"
 #include "lapi/futex.h"
 #include "lapi/syscalls.h"
 #include "tst_ansi_color.h"
@@ -978,6 +979,9 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->skip_in_lockdown && tst_lockdown_enabled())
 		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
+	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
+		tst_brk(TCONF, "Running in 32-bit compat mode");
+
 	if (tst_test->needs_cmds) {
 		const char *cmd;
 		char path[PATH_MAX];
diff --git a/testcases/kernel/syscalls/ptrace/ptrace08.c b/testcases/kernel/syscalls/ptrace/ptrace08.c
index f86f69a9c..170cae64c 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace08.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace08.c
@@ -66,14 +66,6 @@ static struct tst_kern_exv kvers[] = {
 
 static void setup(void)
 {
-	/*
-	 * When running in compat mode we can't pass 64 address to ptrace so we
-	 * have to skip the test.
-	 */
-	if (tst_kernel_bits() != KERN_ADDR_BITS)
-		tst_brk(TCONF, "Cannot pass 64bit kernel address in compat mode");
-
-
 	/*
 	 * The original fix for the kernel haven't rejected the kernel address
 	 * right away when breakpoint was modified from userspace it was
@@ -164,6 +156,11 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.forks_child = 1,
+	/*
+	 * When running in compat mode we can't pass 64 address to ptrace so we
+	 * have to skip the test.
+	 */
+	.skip_in_compat = 1,
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "f67b15037a7a"},
 		{"CVE", "2018-1000199"},
diff --git a/testcases/network/can/cve/can_bcm01.c b/testcases/network/can/cve/can_bcm01.c
index 1c527da7a..d4f1e4ec4 100644
--- a/testcases/network/can/cve/can_bcm01.c
+++ b/testcases/network/can/cve/can_bcm01.c
@@ -11,6 +11,10 @@
  *  Date:   Sat Jun 19 13:18:13 2021 -0300
  *
  *  can: bcm: delay release of struct bcm_op after synchronize_rcu()
+ *
+ * The test is skipped when running in 32-bit compat mode. The kernel
+ * compatibility layer for CAN structures is not implemented at the
+ * time of writing.
  */
 
 #include "config.h"
@@ -137,6 +141,7 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.taint_check = TST_TAINT_W | TST_TAINT_D,
 	.needs_root = 1,
+	.skip_in_compat = 1,
 	.needs_drivers = (const char *const[]) {
 		"vcan",
 		"can-bcm",
-- 
2.33.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 1/2] lib: Cache kernel_bits value
  2021-11-15 15:20 [LTP] [PATCH 1/2] lib: Cache kernel_bits value Richard Palethorpe via ltp
  2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
@ 2021-11-15 16:01 ` Cyril Hrubis
  1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2021-11-15 16:01 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag
  2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
@ 2021-11-15 16:07   ` Cyril Hrubis
  2021-11-16  8:41     ` Richard Palethorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2021-11-15 16:07 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp

Hi!
> +	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
> +		tst_brk(TCONF, "Running in 32-bit compat mode");
                                ^
				Not supported

I think that the message as you wrote it may be slightly confusing.


Other than that it looks good:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag
  2021-11-15 16:07   ` Cyril Hrubis
@ 2021-11-16  8:41     ` Richard Palethorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Palethorpe @ 2021-11-16  8:41 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> +	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
>> +		tst_brk(TCONF, "Running in 32-bit compat mode");
>                                 ^
> 				Not supported
>
> I think that the message as you wrote it may be slightly confusing.
>
>
> Other than that it looks good:
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Thanks, I will fix that up before merging.


-- 
Thank you,
Richard.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-16  8:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 15:20 [LTP] [PATCH 1/2] lib: Cache kernel_bits value Richard Palethorpe via ltp
2021-11-15 15:20 ` [LTP] [PATCH 2/2] lib: Add .skip_in_compat flag Richard Palethorpe via ltp
2021-11-15 16:07   ` Cyril Hrubis
2021-11-16  8:41     ` Richard Palethorpe
2021-11-15 16:01 ` [LTP] [PATCH 1/2] lib: Cache kernel_bits value Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.