1 /* Scalar test for new labelsys syscall subcodes TSOL_GETCLEARANCE
2 and TSOL_SETCLEARANCE available on Solaris 11. */
3
4 #include "scalar.h"
5
6 #include <sys/syscall.h>
7 #include <sys/tsol/tsyscall.h>
8 #include <tsol/label.h>
9
10 __attribute__((noinline))
sys_labelsys(void)11 static void sys_labelsys(void)
12 {
13 GO(SYS_labelsys, "(TSOL_GETCLEARANCE) 2s 1m");
14 SY(SYS_labelsys, x0 + TSOL_GETCLEARANCE, x0 + 1); FAIL;
15 }
16
17 __attribute__((noinline))
sys_labelsys2(void)18 static void sys_labelsys2(void)
19 {
20 m_label_t *label = m_label_alloc(USER_CLEAR);
21 if (label == NULL) {
22 perror("m_label_alloc");
23 return;
24 }
25
26 GO(SYS_labelsys, "(TSOL_GETCLEARANCE) 1s 0m");
27 SY(SYS_labelsys, x0 + TSOL_GETCLEARANCE, label); SUCC;
28
29 m_label_free(label);
30 }
31
32 __attribute__((noinline))
sys_labelsys3(void)33 static void sys_labelsys3(void)
34 {
35 GO(SYS_labelsys, "(TSOL_SETCLEARANCE) 2s 1m");
36 SY(SYS_labelsys, x0 + TSOL_SETCLEARANCE, x0 + 1); FAIL;
37 }
38
39 __attribute__((noinline))
sys_labelsys4(void)40 static void sys_labelsys4(void)
41 {
42 m_label_t *label = m_label_alloc(USER_CLEAR);
43 if (label == NULL) {
44 perror("m_label_alloc");
45 return;
46 }
47
48 int ret = getclearance(label);
49 if (ret != 0) {
50 perror("getclearance");
51 m_label_free(label);
52 return;
53 }
54
55 GO(SYS_labelsys, "(TSOL_SETCLEARANCE) 1s 0m");
56 SY(SYS_labelsys, x0 + TSOL_SETCLEARANCE, label); SUCC;
57
58 m_label_free(label);
59 }
60
main(void)61 int main(void)
62 {
63 /* Uninitialised, but we know px[0] is 0x0. */
64 long *px = malloc(sizeof(long));
65 x0 = px[0];
66
67 /* SYS_labelsys 52 */
68 sys_labelsys();
69 sys_labelsys2();
70 sys_labelsys3();
71 sys_labelsys4();
72
73 return 0;
74 }
75
76