Blame

Date:
Fri Oct 8 15:55:48 2021 UTC
Message:
tweak landlock comment

01
2021-09-19
op
/*
02
2021-09-19
op
* Copyright (c) 2021 Omar Polo <op@omarpolo.com>
03
2021-09-19
op
*
04
2021-09-19
op
* Permission to use, copy, modify, and distribute this software for any
05
2021-09-19
op
* purpose with or without fee is hereby granted, provided that the above
06
2021-09-19
op
* copyright notice and this permission notice appear in all copies.
07
2021-09-19
op
*
08
2021-09-19
op
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
09
2021-09-19
op
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
2021-09-19
op
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
2021-09-19
op
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
2021-09-19
op
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
2021-09-19
op
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
2021-09-19
op
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
2021-09-19
op
*/
16
2021-09-19
op
17
2021-09-19
op
/*
18
2021-09-19
op
* What's the deal with landlock? While distro with linux >= 5.13
19
2021-10-08
op
* have the struct declarations, libc wrappers are missing. The
20
2021-10-08
op
* sample landlock code provided by the authors includes these "shims"
21
2021-10-08
op
* in their example for the landlock API until libc provides them.
22
2021-09-19
op
*
23
2021-09-19
op
* Linux is such a mess sometimes. /rant
24
2021-09-19
op
*/
25
2021-09-19
op
26
2021-09-19
op
#ifndef LANDLOCK_SHIM_H
27
2021-09-19
op
#define LANDLOCK_SHIM_H
28
2021-09-19
op
29
2021-09-19
op
#include <linux/landlock.h>
30
2021-09-19
op
#include <linux/prctl.h>
31
2021-09-19
op
32
2021-09-19
op
#include <sys/prctl.h>
33
2021-09-19
op
#include <sys/stat.h>
34
2021-09-19
op
#include <sys/syscall.h>
35
2021-09-19
op
36
2021-09-19
op
#include <unistd.h>
37
2021-09-19
op
38
2021-09-19
op
#ifndef landlock_create_ruleset
39
2021-09-19
op
static inline int
40
2021-09-19
op
landlock_create_ruleset(const struct landlock_ruleset_attr *attr, size_t size,
41
2021-09-19
op
__u32 flags)
42
2021-09-19
op
{
43
2021-09-19
op
return syscall(__NR_landlock_create_ruleset, attr, size, flags);
44
2021-09-19
op
}
45
2021-09-19
op
#endif
46
2021-09-19
op
47
2021-09-19
op
#ifndef landlock_add_rule
48
2021-09-19
op
static inline int
49
2021-09-19
op
landlock_add_rule(int ruleset_fd, enum landlock_rule_type type,
50
2021-09-19
op
const void *attr, __u32 flags)
51
2021-09-19
op
{
52
2021-09-19
op
return syscall(__NR_landlock_add_rule, ruleset_fd, type, attr, flags);
53
2021-09-19
op
}
54
2021-09-19
op
#endif
55
2021-09-19
op
56
2021-09-19
op
#ifndef landlock_restrict_self
57
2021-09-19
op
static inline int
58
2021-09-19
op
landlock_restrict_self(int ruleset_fd, __u32 flags)
59
2021-09-19
op
{
60
2021-09-19
op
return syscall(__NR_landlock_restrict_self, ruleset_fd, flags);
61
2021-09-19
op
}
62
2021-09-19
op
#endif
63
2021-09-19
op
64
2021-09-19
op
#endif /* LANDLOCK_SHIM_H */