Skip to content

Commit 51b9ba4

Browse files
committed
bpf: Skip oracle for subprogs
Signed-off-by: Paul Chaignon <[email protected]>
1 parent 22ffa93 commit 51b9ba4

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

kernel/bpf/oracle.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ int save_state_in_oracle(struct bpf_verifier_env *env, int insn_idx)
3535
struct bpf_insn_aux_data *aux = cur_aux(env);
3636
struct bpf_oracle_state_list *new_sl;
3737

38+
if (env->subprog_cnt > 1)
39+
/* Skip the oracle if subprogs are used. */
40+
return 0;
41+
3842
if (!aux->oracle_states) {
3943
aux->oracle_states = kmalloc(sizeof(struct list_head), GFP_KERNEL_ACCOUNT);
4044
if (!aux->oracle_states)
@@ -144,11 +148,14 @@ struct bpf_prog *patch_oracle_check_insn(struct bpf_verifier_env *env, struct bp
144148
struct bpf_insn_aux_data *aux = &env->insn_aux_data[i];
145149
struct list_head *head = aux->oracle_states;
146150
struct bpf_insn *insn_buf = env->insn_buf;
147-
struct bpf_prog *new_prog;
151+
struct bpf_prog *new_prog = env->prog;
152+
if (env->subprog_cnt > 1)
153+
/* Skip the oracle if subprogs are used. */
154+
goto noop;
148155
int num_oracle_states = list_count_nodes(head);
149156
int err;
150157
if (!num_oracle_states)
151-
return NULL;
158+
goto noop;
152159
struct bpf_map *inner_map = create_inner_oracle_map(num_oracle_states);
153160
if (IS_ERR(inner_map))
154161
return (void *)inner_map;
@@ -179,6 +186,10 @@ struct bpf_prog *patch_oracle_check_insn(struct bpf_verifier_env *env, struct bp
179186
return ERR_PTR(err);
180187

181188
return new_prog;
189+
190+
noop:
191+
*cnt = 1;
192+
return new_prog;
182193
}
183194

184195
int populate_oracle_map(struct bpf_verifier_env *env, struct bpf_map *oracle_map)
@@ -238,7 +249,8 @@ struct bpf_map *create_oracle_map(struct bpf_verifier_env *env)
238249
struct bpf_map *map = NULL, *inner_map;
239250
int err;
240251

241-
if (env->num_prune_points == 0)
252+
if (env->num_prune_points == 0 || env->subprog_cnt > 1)
253+
/* Skip the oracle if subprogs are used. */
242254
return map;
243255

244256
union bpf_attr map_attr = {

kernel/bpf/verifier.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22645,8 +22645,6 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
2264522645
for (i = 0; i < insn_cnt;) {
2264622646
if (is_prune_point(env, i + delta)) {
2264722647
new_prog = patch_oracle_check_insn(env, insn, i + delta, &cnt);
22648-
if (!new_prog)
22649-
continue;
2265022648
if (IS_ERR(new_prog))
2265122649
return PTR_ERR(new_prog);
2265222650

0 commit comments

Comments
 (0)