Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing the last program fd will detach a link #4135

Open
lmb opened this issue Jan 13, 2025 · 0 comments
Open

Closing the last program fd will detach a link #4135

lmb opened this issue Jan 13, 2025 · 0 comments
Assignees
Labels
bug Something isn't working P2 triaged Discussed in a triage meeting
Milestone

Comments

@lmb
Copy link
Collaborator

lmb commented Jan 13, 2025

Describe the bug

Closing the last reference to a program acts like an implicit link detach. See

REQUIRE(hook.attach_link(program_fd, nullptr, 0, &link) == EBPF_SUCCESS);
// Call bpf_object__close() which will close the program fd. That should
// detach the program from the hook and unload the program.
bpf_object__close(unique_object.release());

This is the opposite of what happens on Linux: a live link (pinned or otherwise) will keep the program alive until either the last reference is closed or the link is explicitly detached.

According to @saxena-anurag the ownership in the runtime is currently from program to link, while it should probably be the link holding on to a refcount on the program.

OS information

No response

Steps taken to reproduce bug

  1. Load a program
  2. Attach it via a link
  3. Close the program

Expected behavior

The attachment should persist until the link is closed / detached / unpinned.

Actual outcome

The attachment is torn down.

Additional details

No response

@lmb lmb added the bug Something isn't working label Jan 13, 2025
@shankarseal shankarseal added triaged Discussed in a triage meeting P2 labels Jan 13, 2025
@shankarseal shankarseal added this to the 2502 milestone Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 triaged Discussed in a triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants