serial: exar: Fix GPIO configuration for Sealevel cards based on XR17V35X
[linux/fpc-iii.git] / kernel / bpf / bpf_lsm.c
blobfb278144e9fd1644c65f75d4944b18c3e1f20b63
1 // SPDX-License-Identifier: GPL-2.0
3 /*
4 * Copyright (C) 2020 Google LLC.
5 */
7 #include <linux/filter.h>
8 #include <linux/bpf.h>
9 #include <linux/btf.h>
10 #include <linux/lsm_hooks.h>
11 #include <linux/bpf_lsm.h>
12 #include <linux/kallsyms.h>
13 #include <linux/bpf_verifier.h>
15 /* For every LSM hook that allows attachment of BPF programs, declare a nop
16 * function where a BPF program can be attached.
18 #define LSM_HOOK(RET, DEFAULT, NAME, ...) \
19 noinline RET bpf_lsm_##NAME(__VA_ARGS__) \
20 { \
21 return DEFAULT; \
24 #include <linux/lsm_hook_defs.h>
25 #undef LSM_HOOK
27 #define BPF_LSM_SYM_PREFX "bpf_lsm_"
29 int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
30 const struct bpf_prog *prog)
32 if (!prog->gpl_compatible) {
33 bpf_log(vlog,
34 "LSM programs must have a GPL compatible license\n");
35 return -EINVAL;
38 if (strncmp(BPF_LSM_SYM_PREFX, prog->aux->attach_func_name,
39 sizeof(BPF_LSM_SYM_PREFX) - 1)) {
40 bpf_log(vlog, "attach_btf_id %u points to wrong type name %s\n",
41 prog->aux->attach_btf_id, prog->aux->attach_func_name);
42 return -EINVAL;
45 return 0;
48 const struct bpf_prog_ops lsm_prog_ops = {
51 const struct bpf_verifier_ops lsm_verifier_ops = {
52 .get_func_proto = tracing_prog_func_proto,
53 .is_valid_access = btf_ctx_access,