All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 03/10] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT
Date: Mon, 29 Aug 2022 17:06:56 +0100	[thread overview]
Message-ID: <20220829160703.874492-4-broonie@kernel.org> (raw)
In-Reply-To: <20220829160703.874492-1-broonie@kernel.org>

When arm64 signal context data overflows the base struct sigcontext it gets
placed in an extra buffer pointed to by a record of type EXTRA_CONTEXT in
the base struct sigcontext which is required to be the last record in the
base struct sigframe. The current validation code attempts to check this
by using GET_RESV_NEXT_HEAD() to step forward from the current record to
the next but that is a macro which assumes it is being provided with a
struct _aarch64_ctx and uses the size there to skip forward to the next
record. Instead validate_extra_context() passes it a struct extra_context
which has a separate size field. This compiles but results in us trying
to validate a termination record in completely the wrong place, at best
failing validation and at worst just segfaulting. Fix this by passing
the struct _aarch64_ctx we meant to into the macro.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/testcases/testcases.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c
index 84c36bee4d82..d98828cb542b 100644
--- a/tools/testing/selftests/arm64/signal/testcases/testcases.c
+++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c
@@ -33,7 +33,7 @@ bool validate_extra_context(struct extra_context *extra, char **err)
 		return false;
 
 	fprintf(stderr, "Validating EXTRA...\n");
-	term = GET_RESV_NEXT_HEAD(extra);
+	term = GET_RESV_NEXT_HEAD(&extra->head);
 	if (!term || term->magic || term->size) {
 		*err = "Missing terminator after EXTRA context";
 		return false;
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
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 v2 03/10] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT
Date: Mon, 29 Aug 2022 17:06:56 +0100	[thread overview]
Message-ID: <20220829160703.874492-4-broonie@kernel.org> (raw)
In-Reply-To: <20220829160703.874492-1-broonie@kernel.org>

When arm64 signal context data overflows the base struct sigcontext it gets
placed in an extra buffer pointed to by a record of type EXTRA_CONTEXT in
the base struct sigcontext which is required to be the last record in the
base struct sigframe. The current validation code attempts to check this
by using GET_RESV_NEXT_HEAD() to step forward from the current record to
the next but that is a macro which assumes it is being provided with a
struct _aarch64_ctx and uses the size there to skip forward to the next
record. Instead validate_extra_context() passes it a struct extra_context
which has a separate size field. This compiles but results in us trying
to validate a termination record in completely the wrong place, at best
failing validation and at worst just segfaulting. Fix this by passing
the struct _aarch64_ctx we meant to into the macro.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/testcases/testcases.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c
index 84c36bee4d82..d98828cb542b 100644
--- a/tools/testing/selftests/arm64/signal/testcases/testcases.c
+++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c
@@ -33,7 +33,7 @@ bool validate_extra_context(struct extra_context *extra, char **err)
 		return false;
 
 	fprintf(stderr, "Validating EXTRA...\n");
-	term = GET_RESV_NEXT_HEAD(extra);
+	term = GET_RESV_NEXT_HEAD(&extra->head);
 	if (!term || term->magic || term->size) {
 		*err = "Missing terminator after EXTRA context";
 		return false;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-08-29 16:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 16:06 [PATCH v2 00/10] kselftest/arm64: EXTRA_CONTEXT related fixes Mark Brown
2022-08-29 16:06 ` Mark Brown
2022-08-29 16:06 ` [PATCH v2 01/10] kselftest/arm64: Enumerate SME rather than SVE vector lengths for za_regs Mark Brown
2022-08-29 16:06   ` Mark Brown
2022-08-29 16:06 ` [PATCH v2 02/10] kselftest/arm64: Validate signal ucontext in place Mark Brown
2022-08-29 16:06   ` Mark Brown
2022-08-29 16:06 ` Mark Brown [this message]
2022-08-29 16:06   ` [PATCH v2 03/10] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Mark Brown
2022-08-29 16:06 ` [PATCH v2 04/10] kselftest/arm64: Fix validation of EXTRA_CONTEXT signal context location Mark Brown
2022-08-29 16:06   ` Mark Brown
2022-08-29 16:06 ` [PATCH v2 05/10] kselftest/arm64: Remove unneeded protype for validate_extra_context() Mark Brown
2022-08-29 16:06   ` Mark Brown
2022-08-29 16:06 ` [PATCH v2 06/10] kselftest/arm64: Only validate each signal context once Mark Brown
2022-08-29 16:06   ` Mark Brown
2022-08-29 16:07 ` [PATCH v2 07/10] kselftest/arm64: Validate contents of EXTRA_CONTEXT blocks Mark Brown
2022-08-29 16:07   ` Mark Brown
2022-08-29 16:07 ` [PATCH v2 08/10] kselftest/arm64: Preserve any EXTRA_CONTEXT in handle_signal_copyctx() Mark Brown
2022-08-29 16:07   ` Mark Brown
2022-08-29 16:07 ` [PATCH v2 09/10] kselftest/arm64: Allow larger buffers in get_signal_context() Mark Brown
2022-08-29 16:07   ` Mark Brown
2022-08-29 16:07 ` [PATCH v2 10/10] kselftest/arm64: Include larger SVE and SME VLs in signal tests Mark Brown
2022-08-29 16:07   ` Mark Brown
2022-09-06 17:44 ` [PATCH v2 00/10] kselftest/arm64: EXTRA_CONTEXT related fixes Catalin Marinas
2022-09-06 17:44   ` Catalin Marinas

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=20220829160703.874492-4-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 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.