[PATCH bpf 0/2] bpf: don't attach links to modules that are still loading

From: Chris Mason

Date: Thu Dec 03 2026 - 15:26:27 EST


Hi everyone,

These are AI generated fixes for two use-after-frees in BPF links.

When a module fails to load, we free it without checking for references.
If somebody creates a link while it's still loading, the link is left
pointing at freed memory. With these applied, the link fails until the
module is live.

Mahanta Jambigi has a patch that makes the module loader wait for those
references instead:

[PATCH v2] module: drain external refs before freeing a failed-init module
https://lore.kernel.org/all/20261201103922.1480284-1-mjambigi@xxxxxxxxxxxxx/

It doesn't cover all of the ways a load can fail, and an open link could
make it wait forever, so I think we need both.

This is on top of v7.4-rc5.

Chris Mason (2):
bpf: Reject raw tracepoint links on coming modules
bpf: Reject kprobe_multi links on coming modules

kernel/trace/bpf_trace.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.55.0