]> granicus.if.org Git - strace/blob - tests/pkey_alloc.c
Remove XLAT_END
[strace] / tests / pkey_alloc.c
1 /*
2  * Check decoding of pkey_alloc syscall.
3  *
4  * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
5  * Copyright (c) 2016-2019 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12 #include "scno.h"
13
14 #ifdef __NR_pkey_alloc
15
16 # include <stdio.h>
17 # include <unistd.h>
18
19 int
20 main(void)
21 {
22         static const kernel_ulong_t flags[] = {
23                 0,
24                 (kernel_ulong_t) 0xbadc0ded00000000ULL,
25                 (kernel_ulong_t) 0xffff0000eeee1111ULL,
26                 (kernel_ulong_t) 0x123456789abcdef0ULL,
27         };
28         static const struct {
29                 kernel_ulong_t val;
30                 const char *str;
31         } rights[] = {
32                 { (kernel_ulong_t) 0xbadc0ded00000002ULL,
33                         sizeof(kernel_ulong_t) > sizeof(int) ?
34                         "PKEY_DISABLE_WRITE|0xbadc0ded00000000" :
35                         "PKEY_DISABLE_WRITE" },
36                 { 0xdec0ded, "PKEY_DISABLE_ACCESS|PKEY_DISABLE_EXECUTE|"
37                                 "0xdec0de8" },
38                 { 0x7, "PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE|"
39                                 "PKEY_DISABLE_EXECUTE" },
40                 { ARG_STR(0) },
41                 { 0xbadc0de8, "0xbadc0de8 /* PKEY_??? */" },
42         };
43
44         long rc;
45         unsigned int i;
46         unsigned int j;
47
48         for (i = 0; i < ARRAY_SIZE(flags); i++) {
49                 for (j = 0; j < ARRAY_SIZE(rights); j++) {
50                         rc = syscall(__NR_pkey_alloc, flags[i], rights[j].val);
51                         printf("pkey_alloc(%#llx, %s) = %s\n",
52                                (unsigned long long) flags[i], rights[j].str,
53                                sprintrc(rc));
54                 }
55         }
56
57         puts("+++ exited with 0 +++");
58
59         return 0;
60 }
61
62 #else
63
64 SKIP_MAIN_UNDEFINED("__NR_pkey_alloc");
65
66 #endif