Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ struct bpf_func_proto {
};
int *ret_btf_id; /* return value btf_id */
bool (*allowed)(const struct bpf_prog *prog);
bool must_not_sleep;
};

/* bpf_context is intentionally undefined structure. Pointer to bpf_context is
Expand Down
1 change: 1 addition & 0 deletions kernel/bpf/task_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ const struct bpf_func_proto bpf_find_vma_proto = {
.arg3_type = ARG_PTR_TO_FUNC,
.arg4_type = ARG_PTR_TO_STACK_OR_NULL,
.arg5_type = ARG_ANYTHING,
.must_not_sleep = false,
};

struct bpf_iter_task_vma_kern_data {
Expand Down
5 changes: 5 additions & 0 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -11431,6 +11431,11 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
return -EINVAL;
}

if (in_sleepable(env) && fn->must_not_sleep) {
verbose(env, "helper call must not sleep, but called in a sleepable prog\n");
return -EINVAL;
}

/* With LD_ABS/IND some JITs save/restore skb from r1. */
changes_data = bpf_helper_changes_pkt_data(func_id);
if (changes_data && fn->arg1_type != ARG_PTR_TO_CTX) {
Expand Down
Loading