Skip to content

Commit c8632ac

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
Merge branch 'bpf-token'
Andrii Nakryiko says: ==================== BPF token This patch set is a combination of three BPF token-related patch sets ([0], [1], [2]) with fixes ([3]) to kernel-side token_fd passing APIs incorporated into relevant patches, bpf_token_capable() changes requested by Christian Brauner, and necessary libbpf and BPF selftests side adjustments. This patch set introduces an ability to delegate a subset of BPF subsystem functionality from privileged system-wide daemon (e.g., systemd or any other container manager) through special mount options for userns-bound BPF FS to a *trusted* unprivileged application. Trust is the key here. This functionality is not about allowing unconditional unprivileged BPF usage. Establishing trust, though, is completely up to the discretion of respective privileged application that would create and mount a BPF FS instance with delegation enabled, as different production setups can and do achieve it through a combination of different means (signing, LSM, code reviews, etc), and it's undesirable and infeasible for kernel to enforce any particular way of validating trustworthiness of particular process. The main motivation for this work is a desire to enable containerized BPF applications to be used together with user namespaces. This is currently impossible, as CAP_BPF, required for BPF subsystem usage, cannot be namespaced or sandboxed, as a general rule. E.g., tracing BPF programs, thanks to BPF helpers like bpf_probe_read_kernel() and bpf_probe_read_user() can safely read arbitrary memory, and it's impossible to ensure that they only read memory of processes belonging to any given namespace. This means that it's impossible to have a mechanically verifiable namespace-aware CAP_BPF capability, and as such another mechanism to allow safe usage of BPF functionality is necessary. BPF FS delegation mount options and BPF token derived from such BPF FS instance is such a mechanism. Kernel makes no assumption about what "trusted" constitutes in any particular case, and it's up to specific privileged applications and their surrounding infrastructure to decide that. What kernel provides is a set of APIs to setup and mount special BPF FS instance and derive BPF tokens from it. BPF FS and BPF token are both bound to its owning userns and in such a way are constrained inside intended container. Users can then pass BPF token FD to privileged bpf() syscall commands, like BPF map creation and BPF program loading, to perform such operations without having init userns privileges. This version incorporates feedback and suggestions ([4]) received on earlier iterations of BPF token approach, and instead of allowing to create BPF tokens directly assuming capable(CAP_SYS_ADMIN), we instead enhance BPF FS to accept a few new delegation mount options. If these options are used and BPF FS itself is properly created, set up, and mounted inside the user namespaced container, user application is able to derive a BPF token object from BPF FS instance, and pass that token to bpf() syscall. As explained in patch #3, BPF token itself doesn't grant access to BPF functionality, but instead allows kernel to do namespaced capabilities checks (ns_capable() vs capable()) for CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, and CAP_SYS_ADMIN, as applicable. So it forms one half of a puzzle and allows container managers and sys admins to have safe and flexible configuration options: determining which containers get delegation of BPF functionality through BPF FS, and then which applications within such containers are allowed to perform bpf() commands, based on namespaces capabilities. Previous attempt at addressing this very same problem ([5]) attempted to utilize authoritative LSM approach, but was conclusively rejected by upstream LSM maintainers. BPF token concept is not changing anything about LSM approach, but can be combined with LSM hooks for very fine-grained security policy. Some ideas about making BPF token more convenient to use with LSM (in particular custom BPF LSM programs) was briefly described in recent LSF/MM/BPF 2023 presentation ([6]). E.g., an ability to specify user-provided data (context), which in combination with BPF LSM would allow implementing a very dynamic and fine-granular custom security policies on top of BPF token. In the interest of minimizing API surface area and discussions this was relegated to follow up patches, as it's not essential to the fundamental concept of delegatable BPF token. It should be noted that BPF token is conceptually quite similar to the idea of /dev/bpf device file, proposed by Song a while ago ([7]). The biggest difference is the idea of using virtual anon_inode file to hold BPF token and allowing multiple independent instances of them, each (potentially) with its own set of restrictions. And also, crucially, BPF token approach is not using any special stateful task-scoped flags. Instead, bpf() syscall accepts token_fd parameters explicitly for each relevant BPF command. This addresses main concerns brought up during the /dev/bpf discussion, and fits better with overall BPF subsystem design. Second part of this patch set adds full support for BPF token in libbpf's BPF object high-level API. Good chunk of the changes rework libbpf feature detection internals, which are the most affected by BPF token presence. Besides internal refactorings, libbpf allows to pass location of BPF FS from which BPF token should be created by libbpf. This can be done explicitly though a new bpf_object_open_opts.bpf_token_path field. But we also add implicit BPF token creation logic to BPF object load step, even without any explicit involvement of the user. If the environment is setup properly, BPF token will be created transparently and used implicitly. This allows for all existing application to gain BPF token support by just linking with latest version of libbpf library. No source code modifications are required. All that under assumption that privileged container management agent properly set up default BPF FS instance at /sys/bpf/fs to allow BPF token creation. libbpf adds support to override default BPF FS location for BPF token creation through LIBBPF_BPF_TOKEN_PATH envvar knowledge. This allows admins or container managers to mount BPF token-enabled BPF FS at non-standard location without the need to coordinate with applications. LIBBPF_BPF_TOKEN_PATH can also be used to disable BPF token implicit creation by setting it to an empty value. [0] https://patchwork.kernel.org/project/netdevbpf/list/?series=805707&state=* [1] https://patchwork.kernel.org/project/netdevbpf/list/?series=810260&state=* [2] https://patchwork.kernel.org/project/netdevbpf/list/?series=809800&state=* [3] https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/ [4] https://lore.kernel.org/bpf/20230704-hochverdient-lehne-eeb9eeef785e@brauner/ [5] https://lore.kernel.org/bpf/[email protected]/ [6] http://vger.kernel.org/bpfconf2023_material/Trusted_unprivileged_BPF_LSFMM2023.pdf [7] https://lore.kernel.org/bpf/[email protected]/ v1->v2: - disable BPF token creation in init userns, and simplify bpf_token_capable() logic (Christian); - use kzalloc/kfree instead of kvzalloc/kvfree (Linus); - few more selftest cases to validate LSM and BPF token interations. Signed-off-by: Andrii Nakryiko <[email protected]> ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents c9f1155 + 906ee42 commit c8632ac

File tree

41 files changed

+2982
-644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2982
-644
lines changed

drivers/media/rc/bpf-lirc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ lirc_mode2_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
110110
case BPF_FUNC_get_prandom_u32:
111111
return &bpf_get_prandom_u32_proto;
112112
case BPF_FUNC_trace_printk:
113-
if (perfmon_capable())
113+
if (bpf_token_capable(prog->aux->token, CAP_PERFMON))
114114
return bpf_get_trace_printk_proto();
115115
fallthrough;
116116
default:

include/linux/bpf.h

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ struct module;
5252
struct bpf_func_state;
5353
struct ftrace_ops;
5454
struct cgroup;
55+
struct bpf_token;
56+
struct user_namespace;
57+
struct super_block;
58+
struct inode;
5559

5660
extern struct idr btf_idr;
5761
extern spinlock_t btf_idr_lock;
@@ -1485,6 +1489,7 @@ struct bpf_prog_aux {
14851489
#ifdef CONFIG_SECURITY
14861490
void *security;
14871491
#endif
1492+
struct bpf_token *token;
14881493
struct bpf_prog_offload *offload;
14891494
struct btf *btf;
14901495
struct bpf_func_info *func_info;
@@ -1609,6 +1614,31 @@ struct bpf_link_primer {
16091614
u32 id;
16101615
};
16111616

1617+
struct bpf_mount_opts {
1618+
kuid_t uid;
1619+
kgid_t gid;
1620+
umode_t mode;
1621+
1622+
/* BPF token-related delegation options */
1623+
u64 delegate_cmds;
1624+
u64 delegate_maps;
1625+
u64 delegate_progs;
1626+
u64 delegate_attachs;
1627+
};
1628+
1629+
struct bpf_token {
1630+
struct work_struct work;
1631+
atomic64_t refcnt;
1632+
struct user_namespace *userns;
1633+
u64 allowed_cmds;
1634+
u64 allowed_maps;
1635+
u64 allowed_progs;
1636+
u64 allowed_attachs;
1637+
#ifdef CONFIG_SECURITY
1638+
void *security;
1639+
#endif
1640+
};
1641+
16121642
struct bpf_struct_ops_value;
16131643
struct btf_member;
16141644

@@ -2097,6 +2127,7 @@ static inline void bpf_enable_instrumentation(void)
20972127
migrate_enable();
20982128
}
20992129

2130+
extern const struct super_operations bpf_super_ops;
21002131
extern const struct file_operations bpf_map_fops;
21012132
extern const struct file_operations bpf_prog_fops;
21022133
extern const struct file_operations bpf_iter_fops;
@@ -2231,24 +2262,26 @@ static inline void bpf_map_dec_elem_count(struct bpf_map *map)
22312262

22322263
extern int sysctl_unprivileged_bpf_disabled;
22332264

2234-
static inline bool bpf_allow_ptr_leaks(void)
2265+
bool bpf_token_capable(const struct bpf_token *token, int cap);
2266+
2267+
static inline bool bpf_allow_ptr_leaks(const struct bpf_token *token)
22352268
{
2236-
return perfmon_capable();
2269+
return bpf_token_capable(token, CAP_PERFMON);
22372270
}
22382271

2239-
static inline bool bpf_allow_uninit_stack(void)
2272+
static inline bool bpf_allow_uninit_stack(const struct bpf_token *token)
22402273
{
2241-
return perfmon_capable();
2274+
return bpf_token_capable(token, CAP_PERFMON);
22422275
}
22432276

2244-
static inline bool bpf_bypass_spec_v1(void)
2277+
static inline bool bpf_bypass_spec_v1(const struct bpf_token *token)
22452278
{
2246-
return cpu_mitigations_off() || perfmon_capable();
2279+
return cpu_mitigations_off() || bpf_token_capable(token, CAP_PERFMON);
22472280
}
22482281

2249-
static inline bool bpf_bypass_spec_v4(void)
2282+
static inline bool bpf_bypass_spec_v4(const struct bpf_token *token)
22502283
{
2251-
return cpu_mitigations_off() || perfmon_capable();
2284+
return cpu_mitigations_off() || bpf_token_capable(token, CAP_PERFMON);
22522285
}
22532286

22542287
int bpf_map_new_fd(struct bpf_map *map, int flags);
@@ -2265,8 +2298,21 @@ int bpf_link_new_fd(struct bpf_link *link);
22652298
struct bpf_link *bpf_link_get_from_fd(u32 ufd);
22662299
struct bpf_link *bpf_link_get_curr_or_next(u32 *id);
22672300

2301+
void bpf_token_inc(struct bpf_token *token);
2302+
void bpf_token_put(struct bpf_token *token);
2303+
int bpf_token_create(union bpf_attr *attr);
2304+
struct bpf_token *bpf_token_get_from_fd(u32 ufd);
2305+
2306+
bool bpf_token_allow_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
2307+
bool bpf_token_allow_map_type(const struct bpf_token *token, enum bpf_map_type type);
2308+
bool bpf_token_allow_prog_type(const struct bpf_token *token,
2309+
enum bpf_prog_type prog_type,
2310+
enum bpf_attach_type attach_type);
2311+
22682312
int bpf_obj_pin_user(u32 ufd, int path_fd, const char __user *pathname);
22692313
int bpf_obj_get_user(int path_fd, const char __user *pathname, int flags);
2314+
struct inode *bpf_get_inode(struct super_block *sb, const struct inode *dir,
2315+
umode_t mode);
22702316

22712317
#define BPF_ITER_FUNC_PREFIX "bpf_iter_"
22722318
#define DEFINE_BPF_ITER_FUNC(target, args...) \
@@ -2507,7 +2553,8 @@ int btf_find_next_decl_tag(const struct btf *btf, const struct btf_type *pt,
25072553
struct bpf_prog *bpf_prog_by_id(u32 id);
25082554
struct bpf_link *bpf_link_by_id(u32 id);
25092555

2510-
const struct bpf_func_proto *bpf_base_func_proto(enum bpf_func_id func_id);
2556+
const struct bpf_func_proto *bpf_base_func_proto(enum bpf_func_id func_id,
2557+
const struct bpf_prog *prog);
25112558
void bpf_task_storage_free(struct task_struct *task);
25122559
void bpf_cgrp_storage_free(struct cgroup *cgroup);
25132560
bool bpf_prog_has_kfunc_call(const struct bpf_prog *prog);
@@ -2626,6 +2673,24 @@ static inline int bpf_obj_get_user(const char __user *pathname, int flags)
26262673
return -EOPNOTSUPP;
26272674
}
26282675

2676+
static inline bool bpf_token_capable(const struct bpf_token *token, int cap)
2677+
{
2678+
return capable(cap) || (cap != CAP_SYS_ADMIN && capable(CAP_SYS_ADMIN));
2679+
}
2680+
2681+
static inline void bpf_token_inc(struct bpf_token *token)
2682+
{
2683+
}
2684+
2685+
static inline void bpf_token_put(struct bpf_token *token)
2686+
{
2687+
}
2688+
2689+
static inline struct bpf_token *bpf_token_get_from_fd(u32 ufd)
2690+
{
2691+
return ERR_PTR(-EOPNOTSUPP);
2692+
}
2693+
26292694
static inline void __dev_flush(void)
26302695
{
26312696
}
@@ -2749,7 +2814,7 @@ static inline int btf_struct_access(struct bpf_verifier_log *log,
27492814
}
27502815

27512816
static inline const struct bpf_func_proto *
2752-
bpf_base_func_proto(enum bpf_func_id func_id)
2817+
bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
27532818
{
27542819
return NULL;
27552820
}

include/linux/filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static inline bool bpf_jit_blinding_enabled(struct bpf_prog *prog)
11401140
return false;
11411141
if (!bpf_jit_harden)
11421142
return false;
1143-
if (bpf_jit_harden == 1 && bpf_capable())
1143+
if (bpf_jit_harden == 1 && bpf_token_capable(prog->aux->token, CAP_BPF))
11441144
return false;
11451145

11461146
return true;

include/linux/lsm_hook_defs.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,17 @@ LSM_HOOK(void, LSM_RET_VOID, audit_rule_free, void *lsmrule)
404404
LSM_HOOK(int, 0, bpf, int cmd, union bpf_attr *attr, unsigned int size)
405405
LSM_HOOK(int, 0, bpf_map, struct bpf_map *map, fmode_t fmode)
406406
LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog)
407-
LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map)
408-
LSM_HOOK(void, LSM_RET_VOID, bpf_map_free_security, struct bpf_map *map)
409-
LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux)
410-
LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux)
407+
LSM_HOOK(int, 0, bpf_map_create, struct bpf_map *map, union bpf_attr *attr,
408+
struct bpf_token *token)
409+
LSM_HOOK(void, LSM_RET_VOID, bpf_map_free, struct bpf_map *map)
410+
LSM_HOOK(int, 0, bpf_prog_load, struct bpf_prog *prog, union bpf_attr *attr,
411+
struct bpf_token *token)
412+
LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free, struct bpf_prog *prog)
413+
LSM_HOOK(int, 0, bpf_token_create, struct bpf_token *token, union bpf_attr *attr,
414+
struct path *path)
415+
LSM_HOOK(void, LSM_RET_VOID, bpf_token_free, struct bpf_token *token)
416+
LSM_HOOK(int, 0, bpf_token_cmd, const struct bpf_token *token, enum bpf_cmd cmd)
417+
LSM_HOOK(int, 0, bpf_token_capable, const struct bpf_token *token, int cap)
411418
#endif /* CONFIG_BPF_SYSCALL */
412419

413420
LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)

include/linux/security.h

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/string.h>
3333
#include <linux/mm.h>
3434
#include <linux/sockptr.h>
35+
#include <linux/bpf.h>
3536
#include <uapi/linux/lsm.h>
3637

3738
struct linux_binprm;
@@ -2064,15 +2065,22 @@ static inline void securityfs_remove(struct dentry *dentry)
20642065
union bpf_attr;
20652066
struct bpf_map;
20662067
struct bpf_prog;
2067-
struct bpf_prog_aux;
2068+
struct bpf_token;
20682069
#ifdef CONFIG_SECURITY
20692070
extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
20702071
extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
20712072
extern int security_bpf_prog(struct bpf_prog *prog);
2072-
extern int security_bpf_map_alloc(struct bpf_map *map);
2073+
extern int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2074+
struct bpf_token *token);
20732075
extern void security_bpf_map_free(struct bpf_map *map);
2074-
extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
2075-
extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
2076+
extern int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2077+
struct bpf_token *token);
2078+
extern void security_bpf_prog_free(struct bpf_prog *prog);
2079+
extern int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2080+
struct path *path);
2081+
extern void security_bpf_token_free(struct bpf_token *token);
2082+
extern int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd);
2083+
extern int security_bpf_token_capable(const struct bpf_token *token, int cap);
20762084
#else
20772085
static inline int security_bpf(int cmd, union bpf_attr *attr,
20782086
unsigned int size)
@@ -2090,21 +2098,42 @@ static inline int security_bpf_prog(struct bpf_prog *prog)
20902098
return 0;
20912099
}
20922100

2093-
static inline int security_bpf_map_alloc(struct bpf_map *map)
2101+
static inline int security_bpf_map_create(struct bpf_map *map, union bpf_attr *attr,
2102+
struct bpf_token *token)
20942103
{
20952104
return 0;
20962105
}
20972106

20982107
static inline void security_bpf_map_free(struct bpf_map *map)
20992108
{ }
21002109

2101-
static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
2110+
static inline int security_bpf_prog_load(struct bpf_prog *prog, union bpf_attr *attr,
2111+
struct bpf_token *token)
21022112
{
21032113
return 0;
21042114
}
21052115

2106-
static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
2116+
static inline void security_bpf_prog_free(struct bpf_prog *prog)
21072117
{ }
2118+
2119+
static inline int security_bpf_token_create(struct bpf_token *token, union bpf_attr *attr,
2120+
struct path *path)
2121+
{
2122+
return 0;
2123+
}
2124+
2125+
static inline void security_bpf_token_free(struct bpf_token *token)
2126+
{ }
2127+
2128+
static inline int security_bpf_token_cmd(const struct bpf_token *token, enum bpf_cmd cmd)
2129+
{
2130+
return 0;
2131+
}
2132+
2133+
static inline int security_bpf_token_capable(const struct bpf_token *token, int cap)
2134+
{
2135+
return 0;
2136+
}
21082137
#endif /* CONFIG_SECURITY */
21092138
#endif /* CONFIG_BPF_SYSCALL */
21102139

include/uapi/linux/bpf.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,36 @@ union bpf_iter_link_info {
847847
* Returns zero on success. On error, -1 is returned and *errno*
848848
* is set appropriately.
849849
*
850+
* BPF_TOKEN_CREATE
851+
* Description
852+
* Create BPF token with embedded information about what
853+
* BPF-related functionality it allows:
854+
* - a set of allowed bpf() syscall commands;
855+
* - a set of allowed BPF map types to be created with
856+
* BPF_MAP_CREATE command, if BPF_MAP_CREATE itself is allowed;
857+
* - a set of allowed BPF program types and BPF program attach
858+
* types to be loaded with BPF_PROG_LOAD command, if
859+
* BPF_PROG_LOAD itself is allowed.
860+
*
861+
* BPF token is created (derived) from an instance of BPF FS,
862+
* assuming it has necessary delegation mount options specified.
863+
* This BPF token can be passed as an extra parameter to various
864+
* bpf() syscall commands to grant BPF subsystem functionality to
865+
* unprivileged processes.
866+
*
867+
* When created, BPF token is "associated" with the owning
868+
* user namespace of BPF FS instance (super block) that it was
869+
* derived from, and subsequent BPF operations performed with
870+
* BPF token would be performing capabilities checks (i.e.,
871+
* CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN) within
872+
* that user namespace. Without BPF token, such capabilities
873+
* have to be granted in init user namespace, making bpf()
874+
* syscall incompatible with user namespace, for the most part.
875+
*
876+
* Return
877+
* A new file descriptor (a nonnegative integer), or -1 if an
878+
* error occurred (in which case, *errno* is set appropriately).
879+
*
850880
* NOTES
851881
* eBPF objects (maps and programs) can be shared between processes.
852882
*
@@ -901,6 +931,8 @@ enum bpf_cmd {
901931
BPF_ITER_CREATE,
902932
BPF_LINK_DETACH,
903933
BPF_PROG_BIND_MAP,
934+
BPF_TOKEN_CREATE,
935+
__MAX_BPF_CMD,
904936
};
905937

906938
enum bpf_map_type {
@@ -951,6 +983,7 @@ enum bpf_map_type {
951983
BPF_MAP_TYPE_BLOOM_FILTER,
952984
BPF_MAP_TYPE_USER_RINGBUF,
953985
BPF_MAP_TYPE_CGRP_STORAGE,
986+
__MAX_BPF_MAP_TYPE
954987
};
955988

956989
/* Note that tracing related programs such as
@@ -995,6 +1028,7 @@ enum bpf_prog_type {
9951028
BPF_PROG_TYPE_SK_LOOKUP,
9961029
BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */
9971030
BPF_PROG_TYPE_NETFILTER,
1031+
__MAX_BPF_PROG_TYPE
9981032
};
9991033

10001034
enum bpf_attach_type {
@@ -1333,6 +1367,9 @@ enum {
13331367

13341368
/* Flag for value_type_btf_obj_fd, the fd is available */
13351369
BPF_F_VTYPE_BTF_OBJ_FD = (1U << 15),
1370+
1371+
/* BPF token FD is passed in a corresponding command's token_fd field */
1372+
BPF_F_TOKEN_FD = (1U << 16),
13361373
};
13371374

13381375
/* Flags for BPF_PROG_QUERY. */
@@ -1411,6 +1448,10 @@ union bpf_attr {
14111448
* type data for
14121449
* btf_vmlinux_value_type_id.
14131450
*/
1451+
/* BPF token FD to use with BPF_MAP_CREATE operation.
1452+
* If provided, map_flags should have BPF_F_TOKEN_FD flag set.
1453+
*/
1454+
__s32 map_token_fd;
14141455
};
14151456

14161457
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -1480,6 +1521,10 @@ union bpf_attr {
14801521
* truncated), or smaller (if log buffer wasn't filled completely).
14811522
*/
14821523
__u32 log_true_size;
1524+
/* BPF token FD to use with BPF_PROG_LOAD operation.
1525+
* If provided, prog_flags should have BPF_F_TOKEN_FD flag set.
1526+
*/
1527+
__s32 prog_token_fd;
14831528
};
14841529

14851530
struct { /* anonymous struct used by BPF_OBJ_* commands */
@@ -1592,6 +1637,11 @@ union bpf_attr {
15921637
* truncated), or smaller (if log buffer wasn't filled completely).
15931638
*/
15941639
__u32 btf_log_true_size;
1640+
__u32 btf_flags;
1641+
/* BPF token FD to use with BPF_BTF_LOAD operation.
1642+
* If provided, btf_flags should have BPF_F_TOKEN_FD flag set.
1643+
*/
1644+
__s32 btf_token_fd;
15951645
};
15961646

15971647
struct {
@@ -1722,6 +1772,11 @@ union bpf_attr {
17221772
__u32 flags; /* extra flags */
17231773
} prog_bind_map;
17241774

1775+
struct { /* struct used by BPF_TOKEN_CREATE command */
1776+
__u32 flags;
1777+
__u32 bpffs_fd;
1778+
} token_create;
1779+
17251780
} __attribute__((aligned(8)));
17261781

17271782
/* The description below is an attempt at providing documentation to eBPF

0 commit comments

Comments
 (0)