verifier.c (0cea651d6fdbcb279a1c5441a419a2f437896e7b) verifier.c (1e12d3ef47d228e4e7d30f9bc5e6744ede90319c)
1// SPDX-License-Identifier: GPL-2.0-only
2/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
3 * Copyright (c) 2016 Facebook
4 * Copyright (c) 2018 Covalent IO, Inc. http://covalent.io
5 */
6#include <uapi/linux/btf.h>
7#include <linux/bpf-cgroup.h>
8#include <linux/kernel.h>

--- 17100 unchanged lines hidden (view full) ---

17109 case BPF_MODIFY_RETURN:
17110 case BPF_TRACE_ITER:
17111 return true;
17112 default:
17113 return false;
17114 }
17115 }
17116 return prog->type == BPF_PROG_TYPE_LSM ||
1// SPDX-License-Identifier: GPL-2.0-only
2/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
3 * Copyright (c) 2016 Facebook
4 * Copyright (c) 2018 Covalent IO, Inc. http://covalent.io
5 */
6#include <uapi/linux/btf.h>
7#include <linux/bpf-cgroup.h>
8#include <linux/kernel.h>

--- 17100 unchanged lines hidden (view full) ---

17109 case BPF_MODIFY_RETURN:
17110 case BPF_TRACE_ITER:
17111 return true;
17112 default:
17113 return false;
17114 }
17115 }
17116 return prog->type == BPF_PROG_TYPE_LSM ||
17117 prog->type == BPF_PROG_TYPE_KPROBE; /* only for uprobes */
17117 prog->type == BPF_PROG_TYPE_KPROBE /* only for uprobes */ ||
17118 prog->type == BPF_PROG_TYPE_STRUCT_OPS;
17118}
17119
17120static int check_attach_btf_id(struct bpf_verifier_env *env)
17121{
17122 struct bpf_prog *prog = env->prog;
17123 struct bpf_prog *tgt_prog = prog->aux->dst_prog;
17124 struct bpf_attach_target_info tgt_info = {};
17125 u32 btf_id = prog->aux->attach_btf_id;

--- 5 unchanged lines hidden (view full) ---

17131 if (prog->aux->sleepable)
17132 /* attach_btf_id checked to be zero already */
17133 return 0;
17134 verbose(env, "Syscall programs can only be sleepable\n");
17135 return -EINVAL;
17136 }
17137
17138 if (prog->aux->sleepable && !can_be_sleepable(prog)) {
17119}
17120
17121static int check_attach_btf_id(struct bpf_verifier_env *env)
17122{
17123 struct bpf_prog *prog = env->prog;
17124 struct bpf_prog *tgt_prog = prog->aux->dst_prog;
17125 struct bpf_attach_target_info tgt_info = {};
17126 u32 btf_id = prog->aux->attach_btf_id;

--- 5 unchanged lines hidden (view full) ---

17132 if (prog->aux->sleepable)
17133 /* attach_btf_id checked to be zero already */
17134 return 0;
17135 verbose(env, "Syscall programs can only be sleepable\n");
17136 return -EINVAL;
17137 }
17138
17139 if (prog->aux->sleepable && !can_be_sleepable(prog)) {
17139 verbose(env, "Only fentry/fexit/fmod_ret, lsm, iter and uprobe programs can be sleepable\n");
17140 verbose(env, "Only fentry/fexit/fmod_ret, lsm, iter, uprobe, and struct_ops programs can be sleepable\n");
17140 return -EINVAL;
17141 }
17142
17143 if (prog->type == BPF_PROG_TYPE_STRUCT_OPS)
17144 return check_struct_ops_btf_id(env);
17145
17146 if (prog->type != BPF_PROG_TYPE_TRACING &&
17147 prog->type != BPF_PROG_TYPE_LSM &&

--- 303 unchanged lines hidden ---
17141 return -EINVAL;
17142 }
17143
17144 if (prog->type == BPF_PROG_TYPE_STRUCT_OPS)
17145 return check_struct_ops_btf_id(env);
17146
17147 if (prog->type != BPF_PROG_TYPE_TRACING &&
17148 prog->type != BPF_PROG_TYPE_LSM &&

--- 303 unchanged lines hidden ---