Linux Test Project
 help / color / mirror / Atom feed
From: "Ricardo B. Marlière" <ricardo@marliere.net>
To: "Petr Vorel" <pvorel@suse.cz>,
	"Andrea Cervesato" <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/8] Refactor mmap03 test
Date: Mon, 10 Feb 2025 08:46:40 -0300	[thread overview]
Message-ID: <D7OQOXDWO2CJ.3VL7P7EKT6642@marliere.net> (raw)
In-Reply-To: <20250210094141.GA1826068@pevik>

On Mon Feb 10, 2025 at 6:41 AM -03, Petr Vorel wrote:
> Hi Andrea, all,
>
> ...
>> - *	07/2001 Ported by Wayne Boyer
>> + * With ia64 and PARISC/hppa, an attempt to access the contents of the
>> + * mapped region should rise signal SIGSEGV.
>
> You kept this:
>  * With ia64 and PARISC/hppa, an attempt to access the contents of the
>  * mapped region should rise signal SIGSEGV.
>
> You kept checking SIGSEGV, but not sigsetjmp() which should cause it (IMHO it
> will not work).

In my initial testing [1], I hit a situation where SIGSEGV was raised in
my Tumbleweed SUT. I eventually found out that it was due to
CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y in openSUSE kernels.

[1]: https://lore.kernel.org/ltp/20250114-conversions-v1-2-7869a9f786d0@suse.com/

I was playing with the following diff here but was unable to catch any
signal in the current version:

diff --git a/testcases/kernel/syscalls/mmap/mmap03.c b/testcases/kernel/syscalls/mmap/mmap03.c
index f22365b259da..25f9c5ce4d18 100644
--- a/testcases/kernel/syscalls/mmap/mmap03.c
+++ b/testcases/kernel/syscalls/mmap/mmap03.c
@@ -22,6 +22,7 @@
  * mapped region should rise signal SIGSEGV.
  */
 
+#include "tst_kconfig.h"
 #include "tst_test.h"
 
 #define TEMPFILE "mmapfile"
@@ -67,7 +68,14 @@ static void run(void)
 
 	SAFE_WAITPID(pid, &status, 0);
 
-#if defined(__ia64__) || defined(__hppa__) || defined(__mips__)
+#if defined(__ia64__) || defined(__hppa__) || defined(__mips__) || defined(__x86_64__)
+	struct tst_kconfig_var kconfig =
+		TST_KCONFIG_INIT("CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS");
+	tst_kconfig_read(&kconfig, 1);
+	if (kconfig.choice == 'y')
+		tst_res(TINFO, "CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y");
+
+	tst_res(TINFO, "%d == 11 (SEGV)?", WTERMSIG(status));
 	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
 		tst_res(TPASS, "SIGSEGV has been received");
 	} else {


BTW, thanks for the mmap cleanup, Andrea!

>
> I wonder if we should care about these old archs. Both ia64 and hppa are
> dropped. The only still living arch is __mips__. But looking at change when it
> mips was added it's quite recent - 2021:
> c7f979b3d ("syscalls/mmap03: Fix SegFault on MIPS")

TIL, thanks :)

-    Ricardo.



>
> @Cyril? Should we keep only mips? And I strongly suspect nobody is testing LTP
> on mips, but we should probably not kill a still living arch.
> If all these archs removed whole fork could be removed.
>
> ...
>> +	tst_res(TINFO, "Map temporary file in memory with PROT_EXEC");
> nit: I would remove it. In case of the problem SAFE_MMAP() will notify,
> otherwise not important.
>
> Also, can we move SAFE_MALLOC() to setup and free to cleanup()
>
> data = SAFE_MALLOC(page_sz);
>
> Kind regards,
> Petr


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

  reply	other threads:[~2025-02-10 11:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10  9:07 [LTP] [PATCH v2 0/8] Cleanup the mmap testing suite Andrea Cervesato
2025-02-10  9:07 ` [LTP] [PATCH v2 1/8] Refactor mmap03 test Andrea Cervesato
2025-02-10  9:41   ` Petr Vorel
2025-02-10 11:46     ` Ricardo B. Marlière [this message]
2025-02-24 16:56     ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 2/8] Refactor mmap10 test Andrea Cervesato
2025-02-24 16:57   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 3/8] Cleanup mmap12 test Andrea Cervesato
2025-02-25 10:17   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 4/8] Cleanup mmap17 test Andrea Cervesato
2025-02-25 15:02   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 5/8] Cleanup mmap18 test Andrea Cervesato
2025-02-25 15:20   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 6/8] Cleanup mmap19 test Andrea Cervesato
2025-02-25 15:21   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 7/8] Cleanup mmap20 test Andrea Cervesato
2025-02-25 15:21   ` Cyril Hrubis
2025-02-10  9:07 ` [LTP] [PATCH v2 8/8] Refactor mmap001 test and move it to mmap21 Andrea Cervesato
2025-02-25 15:51   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D7OQOXDWO2CJ.3VL7P7EKT6642@marliere.net \
    --to=ricardo@marliere.net \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox