diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index f7c27c1cc593..36c2896ee45f 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -605,7 +605,11 @@ static __always_inline int bpf_tree_comp(void *key, struct latch_tree_node *n) if (val < ksym->start) return -1; - if (val >= ksym->end) + /* Ensure that we detect return addresses as part of the program, when + * the final instruction is a call for a program part of the stack + * trace. Therefore, do val > ksym->end instead of val >= ksym->end. + */ + if (val > ksym->end) return 1; return 0;