@cryptotaxi247 / netdata-1 / commits / 137e28a63

Fix PID cleanup loop in EBPF to avoid use-after-free errors (#22098)

- Updated the `ebpf_cleanup_exited_pids` function to correctly handle the iterator by storing the next pointer before resetting PID data.

Stelios Fragkakis committed Mar 31, 2026 at 18:00 UTC 137e28a63ead442416ab21900e5fdc2786a238ef
1 file changed +3 -1
src/collectors/ebpf.plugin/ebpf_apps.c
+3 -1
@@ -829,10 +829,12 @@ void ebpf_del_pid_entry(pid_t pid)
829 static void ebpf_cleanup_exited_pids()
830 {
831 ebpf_pid_data_t *p = NULL;
832 - for (p = ebpf_pids_link_list; p; p = p->next) {
832 + for (p = ebpf_pids_link_list; p;) {
833 + ebpf_pid_data_t *next = p->next;
834 if (!p->has_proc_file) {
835 ebpf_reset_specific_pid_data(p);
836 }
837 + p = next;
838 }
839 }
840