Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2019 ARM Limited
0004  *
0005  * Try to mangle the ucontext from inside a signal handler, toggling
0006  * the execution state bit: this attempt must be spotted by Kernel and
0007  * the test case is expected to be terminated via SEGV.
0008  */
0009 
0010 #include "test_signals_utils.h"
0011 #include "testcases.h"
0012 
0013 static int mangle_invalid_pstate_run(struct tdescr *td, siginfo_t *si,
0014                      ucontext_t *uc)
0015 {
0016     ASSERT_GOOD_CONTEXT(uc);
0017 
0018     /* This config should trigger a SIGSEGV by Kernel */
0019     uc->uc_mcontext.pstate ^= PSR_MODE32_BIT;
0020 
0021     return 1;
0022 }
0023 
0024 struct tdescr tde = {
0025         .sanity_disabled = true,
0026         .name = "MANGLE_PSTATE_INVALID_STATE_TOGGLE",
0027         .descr = "Mangling uc_mcontext with INVALID STATE_TOGGLE",
0028         .sig_trig = SIGUSR1,
0029         .sig_ok = SIGSEGV,
0030         .run = mangle_invalid_pstate_run,
0031 };