Skip to content

api: add MaskedPaths and ReadonlyPaths options #36644

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

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

jessfraz
Copy link
Contributor

@jessfraz jessfraz commented Mar 20, 2018

This adds a RawAccess option to HostConfig for containers so that a user
can pass in an array of paths to not be set as masked or readonly.

closes #36597

- What I did

Added new API options for Masked Paths and ReadonlyPaths to the container HostConfig

- How I did it

Added it to the API and oci package.

- How to verify it

I wrote a test.

- Description for the changelog
RawAccess allows a set of paths to be not set as masked or readonly

- A picture of a cute animal (not mandatory but encouraged)
blizzardslide2

@AkihiroSuda
Copy link
Member

As discussed in opencontainers/runc#1658 (comment) ,
I think we (and runc/runtime-spec maintainers) should consider allowing mount /path even when /path/a is masked, as (IIUC) an alternative to this PR.

@jessfraz
Copy link
Contributor Author

Still would have the problem with read-only though

for i, p := range s.Linux.MaskedPaths {
matched, err := filepath.Match(rawpath, p)
if err != nil {
return fmt.Errorf("masked paths: checking if %s matches %s failed: %v", rawpath, p, err)
Copy link
Member

Choose a reason for hiding this comment

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

Small nitpick/suggestion: maybe errors.Wrapf instead of fmt.Errorf?


// SetRawAccess removes the given raw access paths from the specs MaskedPaths and ReadonlyPaths.
func SetRawAccess(s *specs.Spec, rawaccess []string) error {
// Iterate over the rawaccess paths.
Copy link
Member

Choose a reason for hiding this comment

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

Small nitpick/suggestion: IMHO, this comment is a redundancy.

)

// SetRawAccess removes the given raw access paths from the specs MaskedPaths and ReadonlyPaths.
func SetRawAccess(s *specs.Spec, rawaccess []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Small nitpick/suggestion: can you change from rawaccess to rawAccessPaths?

@boaz0
Copy link
Member

boaz0 commented Mar 21, 2018

It looks like the CI failures aren't related to the change:

  • powerpc failed due to timeout
  • janky failed due to hack/generate-swagger-api.sh. Although, no changes to the API were made:
18:04:17 The result of hack/generate-swagger-api.sh differs
18:04:17 
18:04:17 diff --git a/api/types/container/container_wait.go b/api/types/container/container_wait.go
18:04:17 index 9e3910a6b..06b0f0207 100644
18:04:17 --- a/api/types/container/container_wait.go
18:04:17 +++ b/api/types/container/container_wait.go
18:04:17 @@ -7,14 +7,6 @@ package container
18:04:17  // See hack/generate-swagger-api.sh
18:04:17  // ----------------------------------------------------------------------------
18:04:17  
18:04:17 -// ContainerWaitOKBodyError container waiting error, if any
18:04:17 -// swagger:model ContainerWaitOKBodyError
18:04:17 -type ContainerWaitOKBodyError struct {
18:04:17 -
18:04:17 -	// Details of an error
18:04:17 -	Message string `json:"Message,omitempty"`
18:04:17 -}
18:04:17 -
18:04:17  // ContainerWaitOKBody OK response to ContainerWait operation
18:04:17  // swagger:model ContainerWaitOKBody
18:04:17  type ContainerWaitOKBody struct {
18:04:17 @@ -27,3 +19,11 @@ type ContainerWaitOKBody struct {
18:04:17  	// Required: true
18:04:17  	StatusCode int64 `json:"StatusCode"`
18:04:17  }
18:04:17 +
18:04:17 +// ContainerWaitOKBodyError container waiting error, if any
18:04:17 +// swagger:model ContainerWaitOKBodyError
18:04:17 +type ContainerWaitOKBodyError struct {
18:04:17 +
18:04:17 +	// Details of an error
18:04:17 +	Message string `json:"Message,omitempty"`
18:04:17 +}
18:04:17 
18:04:17 Please update api/swagger.yaml with any api changes, then 
18:04:17 run `hack/generate-swagger-api.sh`.
``

@AkihiroSuda
Copy link
Member

ok, design SGTM

@thaJeztah
Copy link
Member

Discussing in the maintainers meeting, and generally looks like we're okay with the functionality. There's still some discussion on design, and possible alternatives

Some concerns that were brought up:

  • If this will be exposed through the CLI, we need to look closely at the UX, as it may not be as clear as (say) --cap-add SYS_ADMIN that you're giving more privileged to the container, so we should print a warning there (assuming this is gonna be added to the CLI)
  • Another thing brought up is that we should error if someone tries to "unmask" a path that wasn't masked ?

Alternative approaches being discussed:

  • instead of providing what paths to exclude from the defaults, should we have an option to set which paths to mask (i.e., fully override the defaults)?
  • @AkihiroSuda's suggestion to use the mounts API was also discussed; wondering if this would work (inconclusive 😅)

@jessfraz
Copy link
Contributor Author

agree with documenting it to make sure its clear.

I am okay with any design you all want so I'll update accordingly when it's decided :)

@thaJeztah
Copy link
Member

Thanks! Yes, I'll pester some people to see if we can come to a decision asap 😂

@jessfraz
Copy link
Contributor Author

jessfraz commented Mar 22, 2018 via email

@justincormack
Copy link
Contributor

I dont think it makes sense to error if unmasking a path thats not masked, they vary by docker version quite a it so its better to be able to over specify.

@thaJeztah
Copy link
Member

Brought this up in a maintainers meeting again to see if I could get things moving. Looks like generally people were in favor of;

Instead of providing what paths to exclude from the defaults, provide al list of paths to mask (i.e., fully override the defaults)

Also; for the time being; make this an API-only change (no option on the CLI yet to configure this)

@justincormack let me know if you agree with the above ^^

@jessfraz
Copy link
Contributor Author

Also; for the time being; make this an API-only change (no option on the CLI yet to configure this)

oh cool, i will just wait on confirmation, thanks so much for moving this along :) you all are the dopest

@AkihiroSuda
Copy link
Member

@justincormack SGTY? ^^

@justincormack
Copy link
Contributor

Yes an override list (possibly empty) seems cleanest. That way you dont need to know which ones to remove. SGTM.

@jessfraz
Copy link
Contributor Author

updated and added integration tests

@jessfraz
Copy link
Contributor Author

janky is mad at me, its like he doesn't remember who his mom is

@cpuguy83
Copy link
Member

Janky, that's your mommy! Be nice!

@@ -113,3 +115,134 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
expected = fmt.Sprintf("StartPeriod in Healthcheck cannot be less than %s", container.MinimumDuration)
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
}

func (s *DockerSuite) TestAPICreateWithCustomMaskedPaths(c *check.C) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you move these to integration/container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah so I had them there and they weren't working but will try again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok updated!

@jessfraz
Copy link
Contributor Author

jessfraz commented Jun 6, 2018

ok should be good now :)

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🔥

@boaz0
Copy link
Member

boaz0 commented Jun 6, 2018

LGTM 💯

Copy link
Member

@thaJeztah thaJeztah 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!

@AkihiroSuda
Copy link
Member

Any update about docker cli? ^^

@jessfraz
Copy link
Contributor Author

oh will do, sorry been busy with other work things, i promise it is on the list :) probably will open a proposal next week

jessfraz added a commit to jessfraz/kubernetes that referenced this pull request Aug 30, 2018
This vendor change was purely for the changes in docker to allow for
setting the Masked and Read-only paths.

See: moby/moby#36644

But because of the docker dep update it also needed cadvisor to be
updated and winterm due to changes in pkg/tlsconfig in docker

See: google/cadvisor#1967

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[proposal]: option to not mask or set read-only paths in /proc
9 participants