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

Harden link state machine #2396

Merged
merged 2 commits into from
Apr 27, 2023
Merged

Harden link state machine #2396

merged 2 commits into from
Apr 27, 2023

Conversation

Alan-Jowett
Copy link
Member

Resolves: #2328

Description

Fix invalid state transitions in link state machine.

Testing

CI/CD + km stress.

Documentation

No.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
dthaler
dthaler previously approved these changes Apr 27, 2023
@dthaler dthaler added the bug Something isn't working label Apr 27, 2023
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
@dthaler dthaler enabled auto-merge April 27, 2023 18:44
* ATTACHED. When a program is detached from a provider, the state transitions
* to DETACHING. Once the provider is notified, the state transitions to IDLE.
* Legal state transitions are:
* 1. EBPF_LINK_STATE_INITIAL -> EBPF_LINK_STATE_ATTACHING - In ebpf_link_attach_program when the program is being
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to mention the specific (current) functions where this transition is made? Future code changes could make such comments incorrect and thus confusing. IMO, just the part of the comment describing the transition ought to be enough. Thoughts?

@@ -154,10 +164,23 @@ _ebpf_link_extension_changed_callback(

// Complete detach.
if (provider_data == NULL) {
// Check if the link is in the process of attaching.
if (link->state == EBPF_LINK_STATE_DETACHING) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above this line mentions 'attaching' but we're checking for detaching? (EBPF_LINK_STATE_DETACHING

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Comment is wrong.

@dthaler dthaler added this pull request to the merge queue Apr 27, 2023
Merged via the queue into microsoft:main with commit 0314806 Apr 27, 2023
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eBPF link object must not invoke associated program until the link object's state is ATTACHED.
3 participants