accel/ivpu: Move recovery work to system_unbound_wq
[drm/drm-misc.git] / tools / perf / tests / workloads / landlock.c
blobe2b5ef647c0978189f0afaf25b3245602d387b2d
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/compiler.h>
3 #include <linux/types.h>
4 #include <unistd.h>
5 #include "../tests.h"
7 /* This workload was initially added to test enum augmentation with BTF in perf
8 * trace because its the only syscall that has an enum argument. Since it is
9 * a recent addition to the Linux kernel (at the time of the introduction of this
10 * 'perf test' workload) we just add the required types and defines here instead
11 * of including linux/landlock, that isn't available in older systems.
13 * We are not interested in the the result of the syscall, just in intercepting
14 * its arguments.
17 #ifndef __NR_landlock_add_rule
18 #define __NR_landlock_add_rule 445
19 #endif
21 #ifndef LANDLOCK_ACCESS_FS_READ_FILE
22 #define LANDLOCK_ACCESS_FS_READ_FILE (1ULL << 2)
24 #define LANDLOCK_RULE_PATH_BENEATH 1
26 struct landlock_path_beneath_attr {
27 __u64 allowed_access;
28 __s32 parent_fd;
30 #endif
32 #ifndef LANDLOCK_ACCESS_NET_CONNECT_TCP
33 #define LANDLOCK_ACCESS_NET_CONNECT_TCP (1ULL << 1)
35 #define LANDLOCK_RULE_NET_PORT 2
37 struct landlock_net_port_attr {
38 __u64 allowed_access;
39 __u64 port;
41 #endif
43 static int landlock(int argc __maybe_unused, const char **argv __maybe_unused)
45 int fd = 11, flags = 45;
47 struct landlock_path_beneath_attr path_beneath_attr = {
48 .allowed_access = LANDLOCK_ACCESS_FS_READ_FILE,
49 .parent_fd = 14,
52 struct landlock_net_port_attr net_port_attr = {
53 .port = 19,
54 .allowed_access = LANDLOCK_ACCESS_NET_CONNECT_TCP,
57 syscall(__NR_landlock_add_rule, fd, LANDLOCK_RULE_PATH_BENEATH,
58 &path_beneath_attr, flags);
60 syscall(__NR_landlock_add_rule, fd, LANDLOCK_RULE_NET_PORT,
61 &net_port_attr, flags);
63 return 0;
66 DEFINE_WORKLOAD(landlock);