From: Mark Brown <broonie@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Shuah Khan <shuah@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kselftest@vger.kernel.org, Mark Brown <broonie@kernel.org>
Subject: [PATCH v1 02/10] kselftest/arm64: Validate signal ucontext in place
Date: Mon, 15 Aug 2022 14:32:28 +0100 [thread overview]
Message-ID: <20220815133236.235464-3-broonie@kernel.org> (raw)
In-Reply-To: <20220815133236.235464-1-broonie@kernel.org>
In handle_input_signal_copyctx() we use ASSERT_GOOD_CONTEXT() to validate
that the context we are saving meets expectations however we do this on
the saved copy rather than on the actual signal context passed in. This
breaks validation of EXTRA_CONTEXT since we attempt to validate the ABI
requirement that the additional space supplied is immediately after the
termination record in the standard context which will not be the case
after it has been copied to another location.
Fix this by doing the validation before we copy. Note that nothing actually
looks inside the EXTRA_CONTEXT at present.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
.../testing/selftests/arm64/signal/test_signals_utils.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.c b/tools/testing/selftests/arm64/signal/test_signals_utils.c
index b588d10afd5b..a54dc1b6f35c 100644
--- a/tools/testing/selftests/arm64/signal/test_signals_utils.c
+++ b/tools/testing/selftests/arm64/signal/test_signals_utils.c
@@ -165,12 +165,15 @@ static bool handle_signal_ok(struct tdescr *td,
}
static bool handle_signal_copyctx(struct tdescr *td,
- siginfo_t *si, void *uc)
+ siginfo_t *si, void *uc_in)
{
+ ucontext_t *uc = uc_in;
+
+ ASSERT_GOOD_CONTEXT(uc);
+
/* Mangling PC to avoid loops on original BRK instr */
- ((ucontext_t *)uc)->uc_mcontext.pc += 4;
+ uc->uc_mcontext.pc += 4;
memcpy(td->live_uc, uc, td->live_sz);
- ASSERT_GOOD_CONTEXT(td->live_uc);
td->live_uc_valid = 1;
fprintf(stderr,
"GOOD CONTEXT grabbed from sig_copyctx handler\n");
--
2.30.2
next prev parent reply other threads:[~2022-08-15 13:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 13:32 [PATCH v1 00/10] kselftest/arm64: EXTRA_CONTEXT related fixes Mark Brown
2022-08-15 13:32 ` [PATCH v1 01/10] kselftest/arm64: Enumerate SME rather than SVE vector lengths for za_regs Mark Brown
2022-08-15 13:32 ` Mark Brown [this message]
2022-08-15 13:32 ` [PATCH v1 03/10] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Mark Brown
2022-08-15 13:32 ` [PATCH v1 04/10] kselftest/arm64: Fix validation of EXTRA_CONTEXT signal context location Mark Brown
2022-08-15 13:32 ` [PATCH v1 05/10] kselftest/arm64: Remove unneeded protype for validate_extra_context() Mark Brown
2022-08-15 13:32 ` [PATCH v1 06/10] kselftest/arm64: Only validate each signal context once Mark Brown
2022-08-15 13:32 ` [PATCH v1 07/10] kselftest/arm64: Validate contents of EXTRA_CONTEXT blocks Mark Brown
2022-08-15 13:32 ` [PATCH v1 08/10] kselftest/arm64: Preserve any EXTRA_CONTEXT in handle_signal_copyctx() Mark Brown
2022-08-15 13:32 ` [PATCH v1 09/10] kselftest/arm64: Allow larger buffers in get_signal_context() Mark Brown
2022-08-15 13:32 ` [PATCH v1 10/10] kselftest/arm64: Include larger SVE and SME VLs in signal tests Mark Brown
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=20220815133236.235464-3-broonie@kernel.org \
--to=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=will@kernel.org \
/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