Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Proxy: Socket file 'other' permission changes to support ACRN Hypervisor#193

Closed
vijaydhanraj wants to merge 6 commits intokata-containers:masterfrom
vijaydhanraj:acrn-proxy
Closed

Proxy: Socket file 'other' permission changes to support ACRN Hypervisor#193
vijaydhanraj wants to merge 6 commits intokata-containers:masterfrom
vijaydhanraj:acrn-proxy

Conversation

@vijaydhanraj
Copy link

When binding the socket with the file path, the socket file permission
is changed to 755. The reason being the following,

Bind system call sets the socket file permission(mode) based on,
socket FD permission and umask bits set. Socket FD by default is
set to 777 and umask by default is set to 022. This results in 755.
ACRN doesn't plan to have an API to update the umask so added
the workaround in kata proxy, where if the ‘other’ permission
is not disabled, then kata proxy can override and disable it.

Fixes: #191

Signed-off-by: Vijay Dhanraj vijay.dhanraj@intel.com

@vijaydhanraj vijaydhanraj reopened this Jun 7, 2019
@codecov
Copy link

codecov bot commented Jun 7, 2019

Codecov Report

Merging #193 into master will decrease coverage by 0.93%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master     #193      +/-   ##
==========================================
- Coverage   36.56%   35.63%   -0.94%     
==========================================
  Files           2        2              
  Lines         268      275       +7     
==========================================
  Hits           98       98              
- Misses        159      166       +7     
  Partials       11       11

@vijaydhanraj
Copy link
Author

Related to: kata-containers/runtime#1779

Copy link
Member

@amshinde amshinde left a comment

Choose a reason for hiding this comment

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

lgtm

proxy.go Outdated
other := int(fileInfo.Mode().Perm()) & otherMask
err := os.Chmod(agentLogsAddr, os.FileMode(other))
if err != nil {
logger().Infof("Cannot change socket permissions for 'other' %d", err)
Copy link

Choose a reason for hiding this comment

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

use WithField and Error

logger().WithField("error", err).Error("Cannot change socket permissions for 'other'")

Copy link
Author

Choose a reason for hiding this comment

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

done. used WithError instead of WithField as discussed.

proxy.go Outdated
if err != nil {
logger().Infof("Cannot change socket permissions for 'other' %d", err)
} else {
logger().Infof("Chaning socket permissions to %4.4o", other)
Copy link

Choose a reason for hiding this comment

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

please move this log before os.Chmod and use WithField instead of %4.4o

Copy link
Author

Choose a reason for hiding this comment

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

done

proxy.go Outdated
other := int(fileInfo.Mode().Perm()) & otherMask
if other != 0 {
return fmt.Errorf("All socket permissions for 'other' should be disabled, got %3.3o", other)
logger().Infof("All socket permissions for 'other' should be disabled, got %4.4o", int(fileInfo.Mode().Perm()))
Copy link

Choose a reason for hiding this comment

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

use WithField instead of %4.4o

Copy link
Author

Choose a reason for hiding this comment

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

done

@devimc
Copy link

devimc commented Jun 10, 2019

/test

Version bump no changes

Signed-off-by: katacontainersbot <katacontainersbot@gmail.com>
proxy.go Outdated
if other != 0 {
return fmt.Errorf("All socket permissions for 'other' should be disabled, got %3.3o", other)
logger().WithField("socket permissions", fmt.Sprintf("%4.4o", fileInfo.Mode().Perm())).
Infof("All socket permissions for 'other' should be disabled")

Choose a reason for hiding this comment

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

Nit: This can now be Info() as you don't have any formats to expand in the string.

Copy link
Author

Choose a reason for hiding this comment

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

done.

proxy.go Outdated
Infof("All socket permissions for 'other' should be disabled")

// Setting permissions socket for "other" to 0.
otherMask := 0770

Choose a reason for hiding this comment

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

You could make this const

Copy link
Author

Choose a reason for hiding this comment

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

This is actually not a declaration. I was trying to reassign a new value to the previously declared variable.
PS: I have now changed this from a declaration to an assignment.

Choose a reason for hiding this comment

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

Good point! 😄

proxy.go Outdated
// Setting permissions socket for "other" to 0.
otherMask := 0770
other := int(fileInfo.Mode().Perm()) & otherMask
logger().WithField("other", fmt.Sprintf("%4.4o", other)).Infof("Chaning socket permissions of 'other'")

Choose a reason for hiding this comment

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

Nits:

  • typo: "Changing".
  • You can also use Info() here rather than Infof().

Copy link
Author

Choose a reason for hiding this comment

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

done.

When binding the socket with the file path, the socket file permission
is changed to 755. The reason being the following,

Bind system call sets the socket file permission(mode) based on,
socket FD permission and umask bits set. Socket FD by default is
set to 777 and umask by default is set to 022. This results in 755.
ACRN doesn't plan to have an API to update the umask so added
the workaround in kata proxy, where if the ‘other’ permission
is not disabled, then kata proxy can override and disable it.

v1->v2:
Changed formatting for logging proxy trace.

Fixes: kata-containers#191

Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
@vijaydhanraj
Copy link
Author

@GWhaley: Can you please help me reproduce the PR-check failure?

…branch-bump

# Kata Containers 1.8.0-alpha1
@grahamwhaley
Copy link
Contributor

Hi @vijaydhanraj Looks like we need to re-trigger the CIs as you updated the PR, so first we:
/test

and then, it looks like the PR-check CI had some sort of system failure, so let's re-trigger that as well:
/zuul-recheck

and then we see how that goes in a couple of hours...

@amshinde
Copy link
Member

@grahamwhaley Looks like the zuul checks are still failing here, can you take a look? I dont see any logs on the build site.

@grahamwhaley
Copy link
Contributor

/zuul-recheck
Oh Zuul zuul.... sigh, so, even though I'm sure we've had the PR-check working (otherwise we could not have merged anything), the logs shown on this link starting from 21st March all show one of NODE_FAILURE/FAILURE/RETRY_LIMIT ?
Maybe the logs only show jobs that fail?? I dunno
https://zuul.opendev.org/t/kata-containers/builds?pipeline=PR-check

Anyway, it looks like this PR (#193 - that is the clue to finding the relevant items for this PR in the log/job list on the above link) shows we hit another NODE_FAILURE. One more time, with gusto then....
/zuul-recheck
(and slapping one a the front of the comment, just in case as well)

@vijaydhanraj
Copy link
Author

/zuul-recheck

@grahamwhaley
Copy link
Contributor

Doh, @vijaydhanraj @amshinde - heh, that is the PR-check we are looking at - that is the WIP Zuul CI check we have that does not currently pass ( see #154 ) - so, don't expect that to pass. The other two Zuul CIs have passed (WIP and SOB) - so, we are good to push the merge maybe...

bergwolf and others added 2 commits June 17, 2019 16:31
Version bump no changes

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
@vijaydhanraj
Copy link
Author

vijaydhanraj commented Jun 17, 2019

Any other comments on this patch? If not, can this be merged?

@jodh-intel
Copy link

ok - ARM CI failure is known, so let's just get this merged...

Proxy: Socket file 'other' permission changes to support ACRN Hypervisor
@jodh-intel
Copy link

... which we cannot do as the branch has conflicts. Could you update please @vijaydhanraj ?

@vijaydhanraj
Copy link
Author

vijaydhanraj commented Jun 20, 2019

@jodh-intel I didn't close the issue, just pushed my changes after rebase. Please let me know anything else is needed.

@amshinde
Copy link
Member

@jodh-intel @vijaydhanraj Looks like this got merged manually vs the github UI.
Weird as I saw this PR open today morning.
@jodh-intel Any idea about this?

@jodh-intel
Copy link

@amshinde - I tried to merge from the UI, got the green "confirm merge" button and clicked it, but then got an error saying the branch was conflicted. However, I checked by grabbing a copy of the PR locally and it merged correctly so this may have been a "github gremlin" 👽 I left the PR in an open state so not sure what happened subsequently.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy: Socket file 'other' permission changes to support ACRN Hypervisor

8 participants