2020-03-29 08:43:49 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Google LLC.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/filter.h>
|
|
|
|
#include <linux/bpf.h>
|
|
|
|
#include <linux/btf.h>
|
2020-03-29 08:43:51 +08:00
|
|
|
#include <linux/lsm_hooks.h>
|
|
|
|
#include <linux/bpf_lsm.h>
|
|
|
|
|
|
|
|
/* For every LSM hook that allows attachment of BPF programs, declare a nop
|
|
|
|
* function where a BPF program can be attached.
|
|
|
|
*/
|
|
|
|
#define LSM_HOOK(RET, DEFAULT, NAME, ...) \
|
|
|
|
noinline RET bpf_lsm_##NAME(__VA_ARGS__) \
|
|
|
|
{ \
|
|
|
|
return DEFAULT; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <linux/lsm_hook_defs.h>
|
|
|
|
#undef LSM_HOOK
|
2020-03-29 08:43:49 +08:00
|
|
|
|
|
|
|
const struct bpf_prog_ops lsm_prog_ops = {
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct bpf_verifier_ops lsm_verifier_ops = {
|
|
|
|
.get_func_proto = bpf_tracing_func_proto,
|
|
|
|
.is_valid_access = btf_ctx_access,
|
|
|
|
};
|