1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Syscall wrappers 4 * 5 * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net> 6 * Copyright © 2019-2020 ANSSI 7 * Copyright © 2021-2025 Microsoft Corporation 8 */ 9 10 #define _GNU_SOURCE 11 #include <linux/landlock.h> 12 #include <sys/syscall.h> 13 #include <sys/types.h> 14 #include <unistd.h> 15 16 #ifndef landlock_create_ruleset 17 static inline int 18 landlock_create_ruleset(const struct landlock_ruleset_attr *const attr, 19 const size_t size, const __u32 flags) 20 { 21 return syscall(__NR_landlock_create_ruleset, attr, size, flags); 22 } 23 #endif 24 25 #ifndef landlock_add_rule 26 static inline int landlock_add_rule(const int ruleset_fd, 27 const enum landlock_rule_type rule_type, 28 const void *const rule_attr, 29 const __u32 flags) 30 { 31 return syscall(__NR_landlock_add_rule, ruleset_fd, rule_type, rule_attr, 32 flags); 33 } 34 #endif 35 36 #ifndef landlock_restrict_self 37 static inline int landlock_restrict_self(const int ruleset_fd, 38 const __u32 flags) 39 { 40 return syscall(__NR_landlock_restrict_self, ruleset_fd, flags); 41 } 42 #endif 43 44 static inline pid_t sys_gettid(void) 45 { 46 return syscall(__NR_gettid); 47 } 48