1 /*
2 * Check decoding of process_mrelease syscall.
3 *
4 * Copyright (c) 2021 Eugene Syromyatnikov <evgsyr@gmail.com>
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #include "tests.h"
11 #include "scno.h"
12
13 #include <inttypes.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <unistd.h>
17
18 #ifndef SKIP_IF_PROC_IS_UNAVAILABLE
19 # define SKIP_IF_PROC_IS_UNAVAILABLE
20 #endif
21
22 #ifndef FD0_STR
23 # define FD0_STR ""
24 #endif
25
26 static const char *errstr;
27
28 static long
29 sys_process_mrelease(int pidfd, unsigned int flags)
30 {
31 static const kernel_ulong_t fill =
32 (kernel_ulong_t) 0xbadc0ded00000000ULL;
33 kernel_ulong_t arg1 = fill | (unsigned int) pidfd;
34 kernel_ulong_t arg2 = fill | flags;
35 kernel_ulong_t arg3 = fill | 0xdeedefed;
36 kernel_ulong_t arg4 = fill | 0xdebeefed;
37 kernel_ulong_t arg5 = fill | 0xdecaffed;
38 kernel_ulong_t arg6 = fill | 0xdeefaced;
39
40 long rc = syscall(__NR_process_mrelease,
41 arg1, arg2, arg3, arg4, arg5, arg6);
42 errstr = sprintrc(rc);
43 return rc;
44 }
45
46 int
47 main(void)
48 {
49 SKIP_IF_PROC_IS_UNAVAILABLE;
50
51 sys_process_mrelease(-1, 0);
52 printf("process_mrelease(-1, 0) = %s\n", errstr);
53
54 sys_process_mrelease(0, 0xfacefeed);
55 printf("process_mrelease(0" FD0_STR ", 0xfacefeed) = %s\n", errstr);
56
57 puts("+++ exited with 0 +++");
58 return 0;
59 }