1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright (C) 2020 Google LLC.
7 #ifndef _LINUX_BPF_LSM_H
8 #define _LINUX_BPF_LSM_H
10 #include <linux/bpf.h>
11 #include <linux/lsm_hooks.h>
15 #define LSM_HOOK(RET, DEFAULT, NAME, ...) \
16 RET bpf_lsm_##NAME(__VA_ARGS__);
17 #include <linux/lsm_hook_defs.h>
20 struct bpf_storage_blob {
21 struct bpf_local_storage __rcu *storage;
24 extern struct lsm_blob_sizes bpf_lsm_blob_sizes;
26 int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
27 const struct bpf_prog *prog);
29 static inline struct bpf_storage_blob *bpf_inode(
30 const struct inode *inode)
32 if (unlikely(!inode->i_security))
35 return inode->i_security + bpf_lsm_blob_sizes.lbs_inode;
38 extern const struct bpf_func_proto bpf_inode_storage_get_proto;
39 extern const struct bpf_func_proto bpf_inode_storage_delete_proto;
40 void bpf_inode_storage_free(struct inode *inode);
42 #else /* !CONFIG_BPF_LSM */
44 static inline int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
45 const struct bpf_prog *prog)
50 static inline struct bpf_storage_blob *bpf_inode(
51 const struct inode *inode)
56 static inline void bpf_inode_storage_free(struct inode *inode)
60 #endif /* CONFIG_BPF_LSM */
62 #endif /* _LINUX_BPF_LSM_H */