Skip to content

Conversation

@jrife
Copy link
Contributor

@jrife jrife commented Nov 7, 2025

No description provided.

jrife added 2 commits November 8, 2025 11:37
Implement update_prog for bpf_tracing_link_lops to enable
BPF_LINK_UPDATE for fentry, fexit, fmod_ret, freplace, and lsm+ links.
The type and expected_attach_type of the new program must match the
original program and the new program must be compatible with the
attachment target.

trace_link_mutex protects concurrent update_prog and release operations
from racing. bpf_tracing_link_release now clears out tr_link->trampoline
to signal to other concurrent link operations that the link is defunct,
so it's also necessary to extend the use of trace_link_mutex to
bpf_tracing_link_show_fdinfo and bpf_tracing_link_fill_link_info which
read tr_link->trampoline. This is similar to other link ops that support
update_prog like netns, sock_map, and xdp links which synchronize link
ops with a global mutex. Since contention should be low, this should be
OK as opposed to adding a per-link mutex. All link operations except
bpf_tracing_link_show_fd_info return -ENOLINK if they execute after the
link is released. In the case of bpf_tracing_link_show_fd_info, this
isn't an option so instead target_obj_id and target_btf_id will be 0 in
the seq_printf call.

Signed-off-by: Jordan Rife <jordan@jrife.io>
While not directly related to making __bpf_trampoline_link_poke support
in-place link program updates, it seemed inconsistent to still update
tr->extension_prog if bpf_arch_text_poke fails when the
non-BPF_TRAMP_REPLACE code path below walks back any changes to tr
if the trampoline update fails. Instead, make sure to not change tr if
the operation fails for BPF_TRAMP_REPLACE.

Signed-off-by: Jordan Rife <jordan@jrife.io>
@jrife jrife force-pushed the jrife/support-tracing-link-update branch from 63e53e3 to d444e26 Compare November 8, 2025 20:45
Exercise a series of edge cases and happy path scenarios across a gamut
of link types (fentry, fmod_ret, fexit, freplace) to test
BPF_LINK_UPDATE behavior for tracing links.

Signed-off-by: Jordan Rife <jordan@jrife.io>
@jrife jrife force-pushed the jrife/support-tracing-link-update branch from d444e26 to 7b54f95 Compare November 8, 2025 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant