~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/workloads/landlock.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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"
  6 
  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.
 12  *
 13  * We are not interested in the the result of the syscall, just in intercepting
 14  * its arguments.
 15  */
 16 
 17 #ifndef __NR_landlock_add_rule
 18 #define __NR_landlock_add_rule 445
 19 #endif
 20 
 21 #ifndef LANDLOCK_ACCESS_FS_READ_FILE
 22 #define LANDLOCK_ACCESS_FS_READ_FILE    (1ULL << 2)
 23 
 24 #define LANDLOCK_RULE_PATH_BENEATH      1
 25 
 26 struct landlock_path_beneath_attr {
 27         __u64 allowed_access;
 28         __s32 parent_fd;
 29 };
 30 #endif
 31 
 32 #ifndef LANDLOCK_ACCESS_NET_CONNECT_TCP
 33 #define LANDLOCK_ACCESS_NET_CONNECT_TCP (1ULL << 1)
 34 
 35 #define LANDLOCK_RULE_NET_PORT          2
 36 
 37 struct landlock_net_port_attr {
 38         __u64 allowed_access;
 39         __u64 port;
 40 };
 41 #endif
 42 
 43 static int landlock(int argc __maybe_unused, const char **argv __maybe_unused)
 44 {
 45         int fd = 11, flags = 45;
 46 
 47         struct landlock_path_beneath_attr path_beneath_attr = {
 48                 .allowed_access = LANDLOCK_ACCESS_FS_READ_FILE,
 49                 .parent_fd = 14,
 50         };
 51 
 52         struct landlock_net_port_attr net_port_attr = {
 53                 .port = 19,
 54                 .allowed_access = LANDLOCK_ACCESS_NET_CONNECT_TCP,
 55         };
 56 
 57         syscall(__NR_landlock_add_rule, fd, LANDLOCK_RULE_PATH_BENEATH,
 58                 &path_beneath_attr, flags);
 59 
 60         syscall(__NR_landlock_add_rule, fd, LANDLOCK_RULE_NET_PORT,
 61                 &net_port_attr, flags);
 62 
 63         return 0;
 64 }
 65 
 66 DEFINE_WORKLOAD(landlock);
 67 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php