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

fix: incorrect CAP_BPF check method #715

Merged
merged 1 commit into from
Jan 4, 2025
Merged

Conversation

hengyoush
Copy link
Contributor

According to the linux man pages: https://man7.org/linux/man-pages/man2/capset.2.html:

Note that the CAP_* values are bit indexes and need to be bit-shifted before ORing into the bit fields.

And added a check for CAP_SYS_ADMIN permissions.

CLOSE #714

@dosubot dosubot bot added the 🐞 bug Something isn't working label Jan 3, 2025
Copy link
Member

@Asphaltt Asphaltt left a comment

Choose a reason for hiding this comment

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

LGTM.

Please use git commit --amend --signoff to sign-off the commit.

@cfc4n
Copy link
Member

cfc4n commented Jan 3, 2025

/review

Copy link

github-actions bot commented Jan 3, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

714 - Fully compliant

Fully compliant requirements:

  • Replace the incorrect CAP_BPF check method with a bit-shifted approach as per the Linux man pages.
  • Ensure the code correctly checks for CAP_BPF permissions.

Not compliant requirements:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

Verify that the bit-shifted CAP_BPF and CAP_SYS_ADMIN checks are implemented correctly and align with the Linux man pages.

capBpfMask := uint32(1 << (unix.CAP_BPF - 32))
capSysAdminMask := uint32(1 << unix.CAP_SYS_ADMIN)
haveBpfCap := (data[1].Permitted&capBpfMask != 0) || (data[0].Permitted&capSysAdminMask != 0)

Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 4, 2025
@cfc4n cfc4n merged commit 06613e0 into gojue:master Jan 4, 2025
6 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 lgtm This PR has been approved by a maintainer Review effort [1-5]: 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check CAP_BPF should use bit shift
3 participants