1
2
3
4
5
6
7
8
9
10#include <signal.h>
11#include <ucontext.h>
12
13#include "test_signals_utils.h"
14#include "testcases.h"
15
16struct fake_sigframe sf;
17
18static int fake_sigreturn_bad_magic_run(struct tdescr *td,
19 siginfo_t *si, ucontext_t *uc)
20{
21 struct _aarch64_ctx *shead = GET_SF_RESV_HEAD(sf), *head;
22
23
24 if (!get_current_context(td, &sf.uc))
25 return 1;
26
27
28 head = get_starting_head(shead, HDR_SZ * 2, GET_SF_RESV_SIZE(sf), NULL);
29 if (!head)
30 return 0;
31
32
33
34
35
36 head->magic = KSFT_BAD_MAGIC;
37 head->size = HDR_SZ;
38 write_terminator_record(GET_RESV_NEXT_HEAD(head));
39
40 ASSERT_BAD_CONTEXT(&sf.uc);
41 fake_sigreturn(&sf, sizeof(sf), 0);
42
43 return 1;
44}
45
46struct tdescr tde = {
47 .name = "FAKE_SIGRETURN_BAD_MAGIC",
48 .descr = "Trigger a sigreturn with a sigframe with a bad magic",
49 .sig_ok = SIGSEGV,
50 .timeout = 3,
51 .run = fake_sigreturn_bad_magic_run,
52};
53