Skip to content

Commit 6012b82

Browse files
brooniectmarinas
authored andcommitted
kselftest/arm64: Copy whole EXTRA context
When copying the EXTRA context our calculation of the amount of data we need to copy is incorrect, we only calculate the amount of data needed within uc_mcontext.__reserved, not taking account of the fixed portion of the context. Add in the offset of the reserved data so that we copy everything we should. This will only cause test failures in cases where the last context in the EXTRA context is smaller than the missing data since we don't currently validate any of the register data and all the buffers we copy into are statically allocated so default to zero meaning that if we walk beyond the end of what we copied we'll encounter what looks like a context with magic and length both 0 which is a valid terminator record. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent a7db82f commit 6012b82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/testing/selftests/arm64/signal/test_signals_utils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ static bool handle_signal_copyctx(struct tdescr *td,
192192
* in the copy, this was previously validated in
193193
* ASSERT_GOOD_CONTEXT().
194194
*/
195-
to_copy = offset + sizeof(struct extra_context) + 16 +
196-
extra->size;
195+
to_copy = __builtin_offsetof(ucontext_t,
196+
uc_mcontext.__reserved);
197+
to_copy += offset + sizeof(struct extra_context) + 16;
198+
to_copy += extra->size;
197199
copied_extra = (struct extra_context *)&(td->live_uc->uc_mcontext.__reserved[offset]);
198200
} else {
199201
copied_extra = NULL;

0 commit comments

Comments
 (0)