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

capability: reduce prctl syscall when setting ambient cap set #163

Closed
lifubang opened this issue Sep 27, 2024 · 0 comments · Fixed by #164
Closed

capability: reduce prctl syscall when setting ambient cap set #163

lifubang opened this issue Sep 27, 2024 · 0 comments · Fixed by #164

Comments

@lifubang
Copy link
Contributor

Even though the ambient cap set is empty, it will always call PR_CAP_AMBIENT_LOWER for each support caps, in most machines, it will call 40 times.
We can use PR_CAP_AMBIENT_CLEAR_ALL to avoid this big for loop to reduce the prctl syscall times.

Please see:

if kind&AMBS == AMBS {
for i := Cap(0); i <= last; i++ {
action := pr_CAP_AMBIENT_LOWER
if c.Get(AMBIENT, i) {
action = pr_CAP_AMBIENT_RAISE
}
err = prctl(pr_CAP_AMBIENT, action, uintptr(i), 0, 0)
if err != nil {

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 a pull request may close this issue.

1 participant