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, mangling the
0006  * DAIF bits in an illegal manner: this attempt must be spotted by Kernel
0007  * and the test case is expected to be terminated via SEGV.
0008  *
0009  */
0010 
0011 #include "test_signals_utils.h"
0012 #include "testcases.h"
0013 
0014 static int mangle_invalid_pstate_run(struct tdescr *td, siginfo_t *si,
0015                      ucontext_t *uc)
0016 {
0017     ASSERT_GOOD_CONTEXT(uc);
0018 
0019     /*
0020      * This config should trigger a SIGSEGV by Kernel when it checks
0021      * the sigframe consistency in valid_user_regs() routine.
0022      */
0023     uc->uc_mcontext.pstate |= PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT;
0024 
0025     return 1;
0026 }
0027 
0028 struct tdescr tde = {
0029         .sanity_disabled = true,
0030         .name = "MANGLE_PSTATE_INVALID_DAIF_BITS",
0031         .descr = "Mangling uc_mcontext with INVALID DAIF_BITS",
0032         .sig_trig = SIGUSR1,
0033         .sig_ok = SIGSEGV,
0034         .run = mangle_invalid_pstate_run,
0035 };