Skip to content

Fix use-after-free race in bpf_prog_info synthesis

Ian Rogers bpf linux-perf-users lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3perf bpf-event: Fix use-after-free in synthesistools/perf/util/bpf-event.c+27 -120 replies
2/3perf bpf-utils: Constify bpil_array_desctools/perf/util/bpf-utils.c+6 -120 replies
3/3perf bpf-utils: Harden get_bpf_prog_info_lineartools/perf/util/bpf-utils.c+33 -100 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNamhyung Kim
SeriesR-b
1/3
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/3] Fix use-after-free race in bpf_prog_info synthesis

The addition of more use of bpf_prog_info for gather BPF metadata in:
https://lore.kernel.org/all/[email protected]/
and the ever richer perf trace testing, such as:
https://lore.kernel.org/all/[email protected]/
frequently triggered a latent perf bug in v6.17 when the perf and libbpf updates came together. The bug would cause segvs and was reported here:
https://lore.kernel.org/lkml/CAP-5=fWJQcmUOP7MuCA2ihKnDAHUCOBLkQFEkQES-1ZZTrgf8Q@mail.gmail.com/

To fix the issue the 1st and 3rd patch are necessary. Both patches address a race of either the sideband thread updating perf's state or the kernel state changing over two system calls.

The use-after-free was introduced by:
https://lore.kernel.org/r/[email protected]
The lack of failing getting the bpf_prog_info for changes in the kernel was introduced in:
https://lore.kernel.org/r/[email protected]

As v6.17 is currently actively segv-ing in perf test I'd recommend these patches go into v6.17 asap.

When running the perf tests on v6.17 I frequently see less critical test failures addressed in:
https://lore.kernel.org/all/[email protected]/

Ian Rogers (3):
perf bpf-event: Fix use-after-free in synthesis
perf bpf-utils: Constify bpil_array_desc
perf bpf-utils: Harden get_bpf_prog_info_linear

 tools/perf/util/bpf-event.c | 39 ++++++++++++++++--------
 tools/perf/util/bpf-utils.c | 61 ++++++++++++++++++++++++-------------
 2 files changed, 66 insertions(+), 34 deletions(-)
Signature · 1 line
2.51.0.355.g5224444f11-goog