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

Add sysctl allowList #693

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

mmirecki
Copy link
Contributor

The tuning-cni allows to set any sysctl on the created container. The admin might however want to restrict the user to a predefined whitelist of sysctls.
This PR is a POC with a proposal on how this could be implemented.

Tuning-cni would try to read a whitelist file from /tuningwhitelist/sysctlwhitelist (NOTE: temporary location only), and check the incoming sysctls agains it. Cni would return error if an unathorized sysctl is detected.
The tuning-cni would behaves as before is the file is missing.

The POC is meant to only show the concept, the actual implementation will probably differ.

@s1061123
Copy link
Contributor

Hi @mmirecki It seems to be good feature for tuning/sysctl, especially Kubernetes with multus.

  • Regarding whitelist/blacklist config file, current PR assumes that the same path of tuning however, I suppose user want to put it in different path from executable binary.
  • The path of whitelist/blacklist could be configurable, I suppose. Of course, we could have default path for that, e.g. /etc/cni/tuning/whitelist.conf or some.
  • How about to use regexp for the sysctl list, instead of simple list of sysctl?

@mmirecki
Copy link
Contributor Author

mmirecki commented Jan 21, 2022

Hi @mmirecki It seems to be good feature for tuning/sysctl, especially Kubernetes with multus.

  • Regarding whitelist/blacklist config file, current PR assumes that the same path of tuning however, I suppose user want to put it in different path from executable binary.

/etc/cni/tuning/whitelist.conf is not the default

  • The path of whitelist/blacklist could be configurable, I suppose. Of course, we could have default path for that, e.g. /etc/cni/tuning/whitelist.conf or some.

I've set this as the default one. I'll add an override when suggestions appear.

  • How about to use regexp for the sysctl list, instead of simple list of sysctl?

Done

@mmirecki mmirecki force-pushed the POC_sysctl_whitelist branch 2 times, most recently from f28219d to 330db60 Compare January 24, 2022 13:31
@mmirecki mmirecki changed the title DRAFT: Add sysctl whitelist Add sysctl whitelist Feb 1, 2022
@mmirecki mmirecki marked this pull request as ready for review February 1, 2022 15:24
Copy link
Contributor

@s1061123 s1061123 left a comment

Choose a reason for hiding this comment

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

As far as I looked, the code seems good to me. I recommend unit-test for the code, in https://github.com/containernetworking/plugins/blob/master/plugins/meta/tuning/tuning_test.go

plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
@mmirecki mmirecki force-pushed the POC_sysctl_whitelist branch 3 times, most recently from 7ef6b59 to 05cfe66 Compare February 9, 2022 11:55
@mmirecki
Copy link
Contributor Author

mmirecki commented Feb 9, 2022

As far as I looked, the code seems good to me. I recommend unit-test for the code, in https://github.com/containernetworking/plugins/blob/master/plugins/meta/tuning/tuning_test.go

@s1061123 , added tests, replied to other comments
Thanks

@cgoncalves
Copy link

Instead of whitelist, consider allow list, permit list or other variations.

@dcbw
Copy link
Member

dcbw commented Feb 9, 2022

@mmirecki I agree with @cgoncalves ; would you mind whitelist -> allowlist?

@mmirecki
Copy link
Contributor Author

mmirecki commented Feb 9, 2022

@mmirecki I agree with @cgoncalves ; would you mind whitelist -> allowlist?

-> allowlist

plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
plugins/meta/tuning/tuning.go Outdated Show resolved Hide resolved
@mmirecki mmirecki changed the title Add sysctl whitelist Add sysctl allowList Feb 24, 2022
Signed-off-by: mmirecki <[email protected]>
Copy link
Contributor

@s1061123 s1061123 left a comment

Choose a reason for hiding this comment

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

It looks good to me. Thank you for the changes!

@dcbw
Copy link
Member

dcbw commented Mar 2, 2022

/lgtm

@squeed
Copy link
Member

squeed commented Mar 2, 2022

Looks good to me. When you have a moment, can you file a PR in https://github.com/containernetworking/cni.dev/ documenting this? Thanks

@squeed squeed merged commit 3512b10 into containernetworking:master Mar 2, 2022
@mmirecki
Copy link
Contributor Author

mmirecki commented Mar 3, 2022

Looks good to me. When you have a moment, can you file a PR in https://github.com/containernetworking/cni.dev/ documenting this? Thanks

@squeed Here's the doc pr: containernetworking/cni.dev#99

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.

5 participants