Skip to content

Add validation for sysctl - #303

Merged
crosbymichael merged 1 commit into
opencontainers:masterfrom
mrunalp:sysctl_validation
Feb 25, 2016
Merged

crosbymichael merged 1 commit into
opencontainers:masterfrom
mrunalp:sysctl_validation

Conversation

@mrunalp

@mrunalp mrunalp commented Sep 25, 2015

Copy link
Copy Markdown
Contributor

/proc/sys isn't completely namespaced and only some properties are allowed
per linux namespace.

The list has been compiled from namespaces(7)

Signed-off-by: Mrunal Patel [email protected]

@mrunalp

mrunalp commented Sep 25, 2015

Copy link
Copy Markdown
Contributor Author

@crosbymichael @LK4D4 ping
cc: @rhatdan

/proc/sys isn't completely namespaced and only some properties are allowed
per linux namespace.

Signed-off-by: Mrunal Patel <[email protected]>
@crosbymichael

Copy link
Copy Markdown
Member

is it even worth having this field when only a few are valid?

@mrunalp

mrunalp commented Sep 25, 2015

Copy link
Copy Markdown
Contributor Author

@crosbymichael We have a lot of customers asking for this. net itself gives a lot of options.

@crosbymichael

Copy link
Copy Markdown
Member

oh, right, i see the prefixes now

@mrunalp

mrunalp commented Sep 25, 2015

Copy link
Copy Markdown
Contributor Author

Also, more options will be made configurable over time from what I gathered talking to kernel engineers.

@rhatdan

rhatdan commented Sep 25, 2015

Copy link
Copy Markdown
Contributor

@jeremyeder PTAL

Are all of these network sysctls actually Namespace aware?

@rhatdan

rhatdan commented Sep 25, 2015

Copy link
Copy Markdown
Contributor

Would we want to make this available to docker as a public interface so that it could catch these early in the parse commands?

@mrunalp

mrunalp commented Sep 25, 2015

Copy link
Copy Markdown
Contributor Author

@rhatdan Yes, we could do that and docker could validate early. Also, @jeder's input will be useful to make sure this list is sane. I am going to look at kernel source code to see if I missed any settings. There is no other way unfortunately.

@rhatdan

rhatdan commented Sep 25, 2015

Copy link
Copy Markdown
Contributor

I think jeder should be @jeremyeder.

@jeremyeder

Copy link
Copy Markdown

@Mrunal No, we can't just pass in the whole "net" sysctl space. Even though some might actually work, there's some strange side-effects; for example you can adjust net.ipv4.tcp_mem in a container but the stack actually respects what's set on the host's kernel.

@rhatdan

rhatdan commented Sep 28, 2015

Copy link
Copy Markdown
Contributor

vm.nr_hugepages

Does not blow up, however not sure it worked correctly.

docker run --privileged -ti --sysctl vm.nr_hugepages=2000 fedora sh
cat /proc/sys/vm/nr_hugepages
285
docker run --privileged -ti --sysctl vm.nr_hugepages=5000 fedora sh
# cat /proc/sys/vm/nr_hugepages
310

@mrunalp

mrunalp commented Sep 28, 2015

Copy link
Copy Markdown
Contributor Author

@jeremyeder Thanks for your input. I will get input from the right folks to create a better list for net and things that may be missing here.

@jeder

jeder commented Sep 28, 2015

Copy link
Copy Markdown

I'm not @jeremyeder, so if he is not responding, you may have an address
wrong.

-John Eder

On Tue, Sep 29, 2015 at 4:43 AM, Mrunal Patel [email protected]
wrote:

@jeremyeder https://github.com/jeremyeder Thanks for your input. I will
get input from the right folks to create a better list for net and things
that may be missing here.

—
Reply to this email directly or view it on GitHub
#303 (comment).

J. Eder

+1 619.847.5579 | +81 80.8903.2817 | [email protected]

@crosbymichael

Copy link
Copy Markdown
Member

Should we validate at all? If you asked for something we just try to do it?

@rhatdan

rhatdan commented Oct 13, 2015

Copy link
Copy Markdown
Contributor

I don't think we should validate. We should leave his up to the user to validate whether it works or not, as we explain in the man pages and docs. Perhaps it would be helpful to have a page where we list sysctls that we know work with a particular kernel version.

Going forward this check is going to be very kernel specific, so verification is often going to be wrong.

@mrunalp

mrunalp commented Oct 13, 2015

Copy link
Copy Markdown
Contributor Author

@crosbymichael @rhatdan Sounds good. If we find a better way we could add it in the future.

@mrunalp mrunalp closed this Oct 13, 2015
@mrunalp mrunalp reopened this Jan 7, 2016
@mrunalp

mrunalp commented Jan 7, 2016

Copy link
Copy Markdown
Contributor Author

Re-opening to see if there is interest in merging this so sysctl could be enabled safely in docker

@mrunalp

mrunalp commented Jan 8, 2016

Copy link
Copy Markdown
Contributor Author

@crosbymichael @LK4D4 WDYT? There are quite a few use cases that are blocked by not enabling this feature in docker.

@vishh

vishh commented Jan 14, 2016

Copy link
Copy Markdown
Contributor

From a community sense, it makes sense to curate a list of safe procfs tunables as part of runc. Until we have a complete list, we could possibly allow a backdoor.

@crosbymichael

Copy link
Copy Markdown
Member

Is there a way were we can move this out of the specs and into hooks/ create/ start lifecycle?

@mrunalp

mrunalp commented Jan 14, 2016

Copy link
Copy Markdown
Contributor Author

It would be possible but a very roundabout way. Any concerns with doing it like in this PR? We could go by the man page and support what is documented.

@rhatdan

rhatdan commented Jan 15, 2016

Copy link
Copy Markdown
Contributor

@crosbymichael Why do you think it would be better in one of those?

@crosbymichael

Copy link
Copy Markdown
Member

@mrunalp do you just want to do the validation at the higher level so that we don't have to recompile or update libcontainer/runc when something changes?

@crosbymichael crosbymichael added this to the 0.0.9 milestone Feb 18, 2016
@rhatdan

rhatdan commented Feb 18, 2016

Copy link
Copy Markdown
Contributor

Not sure you want to do this, if we want to prevent users from shooting themselves in the foot, when doing runc/oci type apps. If we want to protect them, we should protect them in all tools.

One thing we are doing in runc is also looking at whether they disabled the host or ipc namespace, which is pretty difficult to do in the docker cli.

@crosbymichael

Copy link
Copy Markdown
Member

LGTM

@mrunalp

mrunalp commented Feb 19, 2016

Copy link
Copy Markdown
Contributor Author

If we do run into an issue where we have to frequently modify this list then we could add configuration for it. I think we can merge this and then see how it goes.

@hqhq

hqhq commented Feb 19, 2016

Copy link
Copy Markdown
Contributor

So after this, container will never be as privileged as host, isn't this gonna break some users who use container to hack with host, like rancherOS? ping @ibuildthecloud

The validation looks reasonable to me, just think maybe we should make it optional.

@mrunalp

mrunalp commented Feb 19, 2016

Copy link
Copy Markdown
Contributor Author

We could make it optional in privileged mode as the file system is made read only in non privileged anyways.

Sent from my iPhone

On Feb 19, 2016, at 9:36 AM, Qiang Huang [email protected] wrote:

So after this, container will never be as privileged as host, isn't this gonna break some users who use container to hack with host, like rancherOS? ping @ibuildthecloud

The validation looks reasonable to me, just think maybe we should make it optional.

—
Reply to this email directly or view it on GitHub.

@rhatdan

rhatdan commented Feb 19, 2016

Copy link
Copy Markdown
Contributor

Of course in --privileged mode you can just execute sysctl directly.

@mrunalp

mrunalp commented Feb 22, 2016

Copy link
Copy Markdown
Contributor Author

I think we don't need to modify this PR. One can go and set /proc/sys when in privileged mode and there is no harm in the validation when using the CLI so one distinguish between what is safe in container vs being set on the host.

@rhatdan

rhatdan commented Feb 22, 2016

Copy link
Copy Markdown
Contributor

I agree. We are only allowing what we know of as "Namespaced sysctls"

@hqhq

hqhq commented Feb 23, 2016

Copy link
Copy Markdown
Contributor

@mrunalp Do you mean we can make the sysctl validation optional now without any furture modification? Can you explain how to do that?

@mrunalp

mrunalp commented Feb 23, 2016

Copy link
Copy Markdown
Contributor Author

I mean that this patch is sufficient. No special handling of privileged is necessary as /proc/sys is writeable under privileged and allows the user to set sysctls that are not container specific.

Sent from my iPhone

On Feb 23, 2016, at 1:46 PM, Qiang Huang [email protected] wrote:

@mrunalp Do you mean we can make the sysctl validation optional now without any furture modification? Can you explain how to do that?

—
Reply to this email directly or view it on GitHub.

@hqhq

hqhq commented Feb 23, 2016

Copy link
Copy Markdown
Contributor

@mrunalp Thanks for clarification, I'm worry about people might want use sysctl with CLI in --privileged mode which is forbidden by the validation (these non-namespaced sysctls). Anyway we can do that in follow PRs if it do bother some users.

LGTM.

@rhatdan

rhatdan commented Feb 23, 2016

Copy link
Copy Markdown
Contributor

@hqhq I think the current assumption is that --privileged does not change other behaviour in the system. We were discussing similar behaviour with UserNamespace and it was decided that --privileged does not effect userNamespace but a --userns=host is being added to turn off user namespace. I think that precedent would follow here. In that you can do priv ops in the container, but we will continue to block you doing something accidentally.

crosbymichael added a commit that referenced this pull request Feb 25, 2016
@crosbymichael
crosbymichael merged commit fc8c8ed into opencontainers:master Feb 25, 2016
stefanberger pushed a commit to stefanberger/runc that referenced this pull request Sep 8, 2017
narrative cleanup in support of Base Config Compatibility opencontainers#303
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.

8 participants