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

Link for EBPF_ATTACH_TYPE_BIND has type BPF_LINK_TYPE_UNSPEC instead of BPF_LINK_TYPE_PLAIN #4096

Open
lmb opened this issue Dec 17, 2024 · 3 comments · May be fixed by #4139
Open

Link for EBPF_ATTACH_TYPE_BIND has type BPF_LINK_TYPE_UNSPEC instead of BPF_LINK_TYPE_PLAIN #4096

lmb opened this issue Dec 17, 2024 · 3 comments · May be fixed by #4139
Assignees
Labels
bug Something isn't working P2 triaged Discussed in a triage meeting
Milestone

Comments

@lmb
Copy link
Collaborator

lmb commented Dec 17, 2024

Describe the bug

Checking struct bpf_link_info.type for a link backed by a EBPF_ATTACH_TYPE_BIND program shows that the value is BPF_LINK_TYPE_UNSPEC (0) instead of BPF_LINK_TYPE_PLAIN. I'd expect the latter to be the correct value due to the way the hook is initialised:

ebpf_attach_provider_data_t _net_ebpf_bind_hook_provider_data = {
EBPF_ATTACH_PROVIDER_DATA_HEADER, EBPF_PROGRAM_TYPE_BIND_GUID, BPF_ATTACH_TYPE_BIND, BPF_LINK_TYPE_PLAIN};

OS information

No response

Steps taken to reproduce bug

See #4097

Expected behavior

bpf_link_info.type should be BPF_LINK_TYPE_PLAIN for BPF_PROG_TYPE_BIND

Actual outcome

The value is 0.

Additional details

No response

@lmb lmb added the bug Something isn't working label Dec 17, 2024
lmb added a commit to isovalent/ebpf-for-windows that referenced this issue Dec 17, 2024
@shankarseal shankarseal added triaged Discussed in a triage meeting P2 labels Jan 6, 2025
@shankarseal shankarseal added this to the 2501 milestone Jan 6, 2025
@Alan-Jowett
Copy link
Member

@lmb This appears to be a bug in the _single_instance_hook mock class where it's not setting the link_type in the ebpf_attach_provider_data_t.

Does this repro with a live system as well or just in the test mock?

@Alan-Jowett
Copy link
Member

Here is a patch that fixes the bug in the _single_instance_hook mock class:
link_type_fix.patch

@lmb
Copy link
Collaborator Author

lmb commented Jan 7, 2025

I've only encountered this in the tests, so your fix makes sense to me. Can you submit a PR where

// TODO: Should this be BPF_LINK_TYPE_PLAIN?
// See https://github.com/microsoft/ebpf-for-windows/issues/4096
REQUIRE(info.type == BPF_LINK_TYPE_UNSPEC);
is changed to PLAIN?

@Alan-Jowett Alan-Jowett linked a pull request Jan 15, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

4 participants