Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
bpf: Allow return values 0 and 1 for kprobe session
Browse files Browse the repository at this point in the history
[ Upstream commit 17c4b65 ]

The kprobe session program can return only 0 or 1,
instruct verifier to check for that.

Fixes: 535a369 ("bpf: Add support for kprobe session attach")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241108134544.480660-2-jolsa@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
olsajiri authored and gregkh committed Dec 3, 2024
1 parent c68273a commit 89df11f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -15798,6 +15798,15 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
return -ENOTSUPP;
}
break;
case BPF_PROG_TYPE_KPROBE:
switch (env->prog->expected_attach_type) {
case BPF_TRACE_KPROBE_SESSION:
range = retval_range(0, 1);
break;
default:
return 0;
}
break;
case BPF_PROG_TYPE_SK_LOOKUP:
range = retval_range(SK_DROP, SK_PASS);
break;
Expand Down

0 comments on commit 89df11f

Please sign in to comment.