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

libcontainer/specconv/spec_linux: Support empty 'type' for bind mounts #1753

Merged

Conversation

wking
Copy link
Contributor

@wking wking commented Mar 6, 2018

From the “Creating a bind mount” section of mount(2):

If mountflags includes MS_BIND (available since Linux 2.4), then perform a bind mount…

The filesystemtype and data arguments are ignored.

This pull request adds support for configurations that leave the OPTIONAL type unset for bind mounts. There's a related spec-example change in flight with opencontainers/runtime-spec#954, although my personal preference would be a more explicit spec for the whole mount structure (opencontainers/runtime-spec#771).

@cyphar
Copy link
Member

cyphar commented Mar 7, 2018

Looks okay, probably needs a test though. And I think rootfs_linux really needs a good cleanup after this anyway.

@wking wking force-pushed the do-not-require-bind-mount-type branch from 060f9a3 to bc225e7 Compare March 7, 2018 01:43
@wking
Copy link
Contributor Author

wking commented Mar 7, 2018

… probably needs a test though.

What sort of test were you looking for? An integration test? Something in spec_linux_test.go? I've pushed 060f9a3bc225e7 dropping our only internal explicit Type = "bind", does that satisfy your need for testing (do we already test notifySocket.setupSpec somewhere?)?

@cyphar
Copy link
Member

cyphar commented Mar 7, 2018

What sort of test were you looking for? An integration test? Something in spec_linux_test.go?

An integration test would be nice, but if that's too overkill for simply testing bind-mounts, then a spec_linux_test.go would probably be sufficient.

@wking wking force-pushed the do-not-require-bind-mount-type branch 3 times, most recently from ad8781b to 0aa6e4e Compare March 7, 2018 18:22
From the "Creating a bind mount" section of mount(2) [1]:

> If mountflags includes MS_BIND (available since Linux 2.4), then
> perform a bind mount...
>
> The filesystemtype and data arguments are ignored.

This commit adds support for configurations that leave the OPTIONAL
type [2] unset for bind mounts.  There's a related spec-example change
in flight with [3], although my personal preference would be a more
explicit spec for the whole mount structure [4].

[1]: http://man7.org/linux/man-pages/man2/mount.2.html
[2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.1/config.md#L102
[3]: opencontainers/runtime-spec#954
[4]: opencontainers/runtime-spec#771

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented Mar 7, 2018

I've pushed bc225e70aa6e4e adding an integration test for this.

@cyphar
Copy link
Member

cyphar commented Apr 13, 2018

LGTM.

Approved with PullApprove

@crosbymichael
Copy link
Member

crosbymichael commented Apr 16, 2018

LGTM

Approved with PullApprove

@@ -269,13 +269,17 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
flags, pgflags, data, ext := parseMountOptions(m.Options)
source := m.Source
if m.Type == "bind" {
device := m.Type
if flags|unix.MS_BIND != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is always true.

This should be:

if flags&unix.MS_BIND != 0 {

(& vs |)

This is causing opencontainers/runtime-tools#651

I'll prepare a PR.

/cc @dongsupark

alban added a commit to kinvolk/runc that referenced this pull request Jul 18, 2018
PR opencontainers#1753 introduced a test on the mount flags but the binary operator
was wrong, see opencontainers#1753 (comment)

This was noticed when investigating opencontainers/runtime-tools#651

Symptoms: in the container, /proc/self/mountinfo displays some mounts as
follow:

296 279 0:67 / /tmp rw,nosuid - tmpfs /home/dpark/go/src/github.com/opencontainers/runc/tmpfs rw,size=65536k,mode=755

Signed-off-by: Alban Crequy <alban@kinvolk.io>
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.

4 participants