1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2019 ARM Limited
4 *
5 * Try to mangle the ucontext from inside a signal handler, toggling
6 * the execution state bit: this attempt must be spotted by Kernel and
7 * the test case is expected to be terminated via SEGV.
8 */
9
10 #include "test_signals_utils.h"
11 #include "testcases.h"
12
mangle_invalid_pstate_run(struct tdescr * td,siginfo_t * si,ucontext_t * uc)13 static int mangle_invalid_pstate_run(struct tdescr *td, siginfo_t *si,
14 ucontext_t *uc)
15 {
16 ASSERT_GOOD_CONTEXT(uc);
17
18 /* This config should trigger a SIGSEGV by Kernel */
19 uc->uc_mcontext.pstate ^= PSR_MODE32_BIT;
20
21 return 1;
22 }
23
24 struct tdescr tde = {
25 .sanity_disabled = true,
26 .name = "MANGLE_PSTATE_INVALID_STATE_TOGGLE",
27 .descr = "Mangling uc_mcontext with INVALID STATE_TOGGLE",
28 .sig_trig = SIGUSR1,
29 .sig_ok = SIGSEGV,
30 .run = mangle_invalid_pstate_run,
31 };
32