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 default mount options to pass to drivers #176

Merged
merged 1 commit into from
Jul 18, 2018

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented May 14, 2018

I believe we should be running container images mounted with nodev by default.
This would eliminate the disk of a device sneaking into the container without
being on the approved list. This would give us the same or potentially additional
security over the device cgroup.

It would be nice if this could be passed in on an image by image basis. So users
could also specify if they want nosuid images.

Signed-off-by: Daniel J Walsh [email protected]

@rhatdan rhatdan changed the title Add default options to pass to drivers Add default mount options to pass to drivers May 14, 2018
@rhatdan
Copy link
Member Author

rhatdan commented May 22, 2018

@nalind PTAL

@nalind
Copy link
Member

nalind commented May 29, 2018

Looks reasonable, but we'll want to make sure we cover the other drivers, too.

@rhatdan
Copy link
Member Author

rhatdan commented May 30, 2018

@nalind Added support for devicemapper, and returned failures for aufs, vfs and windows. Not sure if this can be done for btrfs or zfs.

@rhatdan
Copy link
Member Author

rhatdan commented Jul 8, 2018

@nalind Rebased PTAL
@rhvgoyal PTAL

Default options to be used to mount container images. Suggested value "nodev".

**ostree_repo=""**
Tell storage drivers to use the specified OSTree repository. Some storage drivers, such as overlay, might use
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we dropped some text here.

Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be in the storage.options.thinpool section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed from my patch set.

@@ -2690,8 +2692,6 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
devices.filesystem = val
case "dm.mkfsarg":
devices.mkfsArgs = append(devices.mkfsArgs, val)
case "dm.mountopt":
devices.mountOptions = joinMountOptions(devices.mountOptions, val)
Copy link
Member

Choose a reason for hiding this comment

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

I get that the devicemapper.mountopt name comes from the driver name and how the option is parsed from the config file, but removing recognition of dm.mountopt seems unnecessary. Can we treat the two names as values for the same case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't this just confuse people? I don't see a reason to have two options to do the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

They do the same thing. Otherwise we're renaming it, and configurations that used one name for the option will start returning an error in anything that uses the newer version of this library.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added back with no documentation.

@@ -300,6 +303,9 @@ func (d *Driver) create(id, parent string, storageOpt map[string]string) error {
}
if parent == "" {
mountoptions := map[string]string{"mountpoint": "legacy"}
if d.options.mountOptions != "" {
mountoptions[d.options.mountOptions] = ""
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it wouldn't handle options of the key=value form (for example, uid=1000) correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

FIxed

@rhatdan
Copy link
Member Author

rhatdan commented Jul 17, 2018

@nalind @giuseppe @rhvgoyal PTAL

nalind
nalind previously requested changes Jul 17, 2018
Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

Looks mostly alright, though I'm not completely sold on setting a default that multiple drivers in the default drivers-to-try list will choke on.

@@ -300,6 +303,10 @@ func (d *Driver) create(id, parent string, storageOpt map[string]string) error {
}
if parent == "" {
mountoptions := map[string]string{"mountpoint": "legacy"}
for _, opt := range strings.Split(d.options.mountOptions, ",") {
val := strings.SplitN(opt, "=", 2)
mountoptions[val[0]] = val[1]
Copy link
Member

Choose a reason for hiding this comment

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

If opt doesn't contain =, wouldn't val[1] be out of bounds?

@rhatdan rhatdan dismissed nalind’s stale review July 17, 2018 19:43

Fixed all issues

} else {
mountoptions[val[0]] = ""
}
}
Copy link
Member

Choose a reason for hiding this comment

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

You're sure this goes here instead of in Get() below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, Fixed.

@rhatdan
Copy link
Member Author

rhatdan commented Jul 17, 2018

I would say a majority do support it.
Supported:
zfs, devicemapper, overlay, aufs

Not supported
Btrfs, Windows, VFS

@rhatdan rhatdan force-pushed the mount-options branch 3 times, most recently from 68f5651 to c3b6d87 Compare July 17, 2018 20:47
@rhatdan
Copy link
Member Author

rhatdan commented Jul 18, 2018

@nalind Now passes tests, Ready to Merge?
@giuseppe @mrunalp PTAL

layers_ffjson.go Outdated
@@ -1,5 +1,5 @@
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
// source: layers.go
// source: ./layers.go
Copy link
Member

Choose a reason for hiding this comment

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

This PR doesn't need this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it does, but I will try without it.

@@ -2664,6 +2664,8 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
}
key = strings.ToLower(key)
switch key {
case "devicemapper.mountopt":
Copy link
Member

Choose a reason for hiding this comment

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

Go ahead and merge this with the case "dm.mountopt": below.

I believe we should be running container images mounted with nodev by default.
This would eliminate the disk of a device sneaking into the container without
being on the approved list.  This would give us the same or potentially additional
security over the device cgroup.

It would be nice if this could be passed in on an image by image basis.  So users
could also specify if they want nosuid images.

Signed-off-by: Daniel J Walsh <[email protected]>
@nalind
Copy link
Member

nalind commented Jul 18, 2018

LGTM

@rhatdan rhatdan merged commit 7098fdc into containers:master Jul 18, 2018
@runcom runcom mentioned this pull request Nov 9, 2018
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.

2 participants