-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
validator: ensure user doesn't try to mount /sys without userns #807
Conversation
Inside a user namespace, mount permissions become more nuanced. sysfs requires you to have either CAP_SYS_ADMIN in the root user namespace (for us this means that we're not using a user namespace) or that you have CAP_SYS_ADMIN in the user namespace the network namespace was created in. This means that having just a user namespace and no private network namespace will result in errors when mounting sysfs[1]. Warn the user about this in the validator. [1]: http://lists.linuxfoundation.org/pipermail/containers/2013-August/033388.html Signed-off-by: Aleksa Sarai <asarai@suse.de>
mmm, I think it's still possible that the user have cap_sys_admin on both the user namespace and the root ? ( though i dont know what's the purpose for that ). I dont think there's a lightweight method to check if an user possess cap_sys_admin either. So i think this LGTM. I guess we can tune it if user complaints :p |
@dqminh I'm not sure how that works actually. Because you lose all capabilities in your previous user namespace if you |
I'm not really a fan of these checks that prohibit runc from trying and letting the system return the error. The point being is that when/if this is fixed in future kernels we have to make a change and push an update for runc instead of not having this type of kernel validation and letting the kernel return the errors. |
My main justification when it comes to things like this is that the errors people get from the operating system don't make sense (you get an error when trying to mount |
idk, pros and cons on both sides. i don't know what is best |
At the very least, we should probably fix the current issues with not actually outputting the error you get inside the init process. Unfortunately, we still have to do a lot if we want to return errors from inside |
I agree with @crosbymichael. The configuration isn't 100% foolproof and we can provide better examples on how to make certain features work. |
I also think we should not prohibit runc from trying because in theory the config could be valid and kernel rules might change. And the poor error message in this case is also pain, maybe some kinds of warning can be a compromise? |
Ya, if we cannot get a useful error message out of the C code then we should probably do a warning and not abort start for something like this. |
The nsenter rewrites have improved the logging part of the nsenter code (though there still is some left to be desired). |
config.md: fix typo of context
Inside a user namespace, mount permissions become more nuanced. sysfs
requires you to have either CAP_SYS_ADMIN in the root user namespace
(for us this means that we're not using a user namespace) or that you
have CAP_SYS_ADMIN in the user namespace the network namespace was
created in. This means that having just a user namespace and no private
network namespace will result in errors when mounting sysfs1. Warn the
user about this in the validator.
Closes #799.
Signed-off-by: Aleksa Sarai asarai@suse.de
/cc @dqminh @mrunalp