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

Update rp_filter only when /proc is write accessible #901

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

SaranBalaji90
Copy link
Contributor

Issue #, if available: #796

Description of changes:
This change is required to remove privileged permission for aws-node pods.

Once this is merged, in the next release we can remove privileged permission for aws-node and perform the operation through init container as described in the Issue link above.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

pkg/procsyswrapper/procsys.go Outdated Show resolved Hide resolved
pkg/networkutils/network_test.go Show resolved Hide resolved
if err != nil {
return errors.Wrapf(err, "failed to configure %s RPF check", primaryIntf)
if n.procSys.IsPathWriteAccessible(primaryIntfRPFilter) {
// Setting RPF will be removed from aws-node when we bump our major version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Bump "major" or "minor" version? Do you mean v1.7.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant when we do 1.7.0

pkg/networkutils/network.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mogren mogren left a comment

Choose a reason for hiding this comment

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

LGTM!

@mogren mogren merged commit 44d0770 into aws:master Apr 7, 2020
@@ -42,3 +45,8 @@ func (p *procSys) Get(key string) (string, error) {
func (p *procSys) Set(key, value string) error {
return ioutil.WriteFile(p.path(key), []byte(value), 0644)
}

// IsPathWriteAccessible verifies if aws-node pod can write to the specified path
func (p *procSys) IsPathWriteAccessible(key string) bool {
Copy link
Contributor

@anguslees anguslees Apr 7, 2020

Choose a reason for hiding this comment

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

This encourages TOCTOU (time of check is not time of use) race attacks btw. A more robust pattern is to just attempt the real Set and see if the error result is "permission denied" (os/error.IsPermission(err) in golang).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops looks like I missed this :/ Here TOCTOU is not possible because when aws-node starts up it will either have /proc accessible or not depending on privileged flag. It won't change during the execution. Please correct me if otherwise.

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.

3 participants