All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: shuah@kernel.org, tglx@linutronix.de,
	dave.hansen@linux.intel.com, bp@alien8.de,
	chang.seok.bae@intel.com
Subject: [PATCH v3 1/3] selftests/x86/sigaltstack: Adjust the test to the kernel's altstack check
Date: Thu, 30 Mar 2023 16:35:18 -0700	[thread overview]
Message-ID: <20230330233520.21937-2-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20230330233520.21937-1-chang.seok.bae@intel.com>

The test assumes an insufficient altstack is allowed. Then it raises a
signal to test the delivery failure due to an altstack overflow.

The kernel now provides the STRICT_SIGALTSTACK_SIZE option to tweak
sigaltstack()'s sanity check to prevent an insufficient altstack.
ENOMEM is returned on the check failure.

Adjust the code to skip the test when this option is on.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
Changes from v2:
* Fix the subsystem name in the subject.

Changes from v1:
* Call out the config name (Shuah Khan).
* Massage the print message (Shuah Khan).
---
 tools/testing/selftests/x86/sigaltstack.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/sigaltstack.c b/tools/testing/selftests/x86/sigaltstack.c
index f689af75e979..22a88b764a8e 100644
--- a/tools/testing/selftests/x86/sigaltstack.c
+++ b/tools/testing/selftests/x86/sigaltstack.c
@@ -88,8 +88,18 @@ static void sigalrm(int sig, siginfo_t *info, void *ctx_void)
 
 static void test_sigaltstack(void *altstack, unsigned long size)
 {
-	if (setup_altstack(altstack, size))
+	if (setup_altstack(altstack, size)) {
+		/*
+		 * The kernel may return ENOMEM when the altstack size
+		 * is insufficient. Skip the test in this case.
+		 */
+		if (errno == ENOMEM && size < at_minstack_size) {
+			printf("[SKIP]\tThe running kernel disallows an insufficient size.\n");
+			return;
+		}
+
 		err(1, "sigaltstack()");
+	}
 
 	sigalrm_expected = (size > at_minstack_size) ? true : false;
 
-- 
2.17.1


  reply	other threads:[~2023-03-30 23:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 17:03 [PATCH v2 0/2] selftests/x86: AMX-related test improvements Chang S. Bae
2022-07-11 17:03 ` [PATCH v2 1/2] selftests/x86/signal: Adjust the test to the kernel's altstack check Chang S. Bae
2022-07-11 17:03 ` [PATCH v2 2/2] selftests/x86/amx: Fix the test to avoid failure when AMX is unavailable Chang S. Bae
2023-03-30 23:35 ` [PATCH v3 0/3] selftests/x86: AMX-related test improvements Chang S. Bae
2023-03-30 23:35   ` Chang S. Bae [this message]
2023-03-30 23:35   ` [PATCH v3 2/3] selftests/x86/amx: Fix the test to avoid failure when AMX is unavailable Chang S. Bae
2023-03-30 23:35   ` [PATCH v3 3/3] selftests/x86/amx: Remove unneeded code Chang S. Bae

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=20230330233520.21937-2-chang.seok.bae@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    /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 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.