Skip to content

Fix: panic in from_pin().attach() for cgroup program types#1516

Open
hieuit095 wants to merge 2 commits into
aya-rs:mainfrom
hieuit095:main
Open

Fix: panic in from_pin().attach() for cgroup program types#1516
hieuit095 wants to merge 2 commits into
aya-rs:mainfrom
hieuit095:main

Conversation

@hieuit095
Copy link
Copy Markdown

@hieuit095 hieuit095 commented Apr 2, 2026

was debugging a user's report about a panic when re-attaching a pinned cgroup program. the issue is that rom_pin doesnt set expected_attach_type on the program data, so calling �ttach() later hits an unwrap on None. fixed by setting it in the three affected rom_pin methods (cgroup_sock, cgroup_sockopt, cgroup_sock_addr).

note: tests cant run locally on windows due to aya-obj using unix-only std::os::fd APIs. this is a pre-existing platform constraint, not related to this change.


This change is Reviewable

@hieuit095 hieuit095 requested a review from a team as a code owner April 2, 2026 12:15
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 2, 2026

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7165c1c
🔍 Latest deploy log https://app.netlify.com/projects/aya-rs-docs/deploys/69cfe6c3aeb30b00089373e7
😎 Deploy Preview https://deploy-preview-1516--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Please write an integration test.

hieuit095 added a commit to hieuit095/aya that referenced this pull request Apr 3, 2026
Adds integration test for aya-rs#1516 fix - CgroupSockAddr::from_pin
now correctly sets expected_attach_type so attach() does not panic.

The test loads a CgroupSockAddr program (connect4 from sk_storage ebpf),
pins it, then loads from pin and attaches. Without the fix, attach()
would panic at expected_attach_type.unwrap().
@hieuit095
Copy link
Copy Markdown
Author

added integration test.

@tamird
Copy link
Copy Markdown
Member

tamird commented Apr 3, 2026

Thanks. I opened #1517 with an alternative fix that removes the expected_attach_type field altogether.

Adds a test that verifies CgroupSockAddr::from_pin() correctly sets
expected_attach_type before attach() is called. Without the fix,
attach() would panic with unwrap on None.

Addresses maintainer request (tamird) for an integration test on PR aya-rs#1516.
@hieuit095
Copy link
Copy Markdown
Author

Added an integration test (cgroup_sock_addr_from_pin_attach) that verifies CgroupSockAddr::from_pin() correctly sets expected_attach_type before �ttach() is called. The test pins a cgroup_sock_addr program, reloads it via rom_pin(), and attaches it to a cgroup — without the fix this would panic at the unwrap() of expected_attach_type inside �ttach().

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.

2 participants