-
Notifications
You must be signed in to change notification settings - Fork 427
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
devpts silently not mounted in unprivileged (user namespace) mode #1186
Comments
Hi @olifre, My apologies for the delay in getting back to you on #857... I've been somewhat busy lately. As discussed in that issue, I've been testing a branch which disables passing "gid=" to the devpts mount when setuid is disabled. However, unfortunately, in further testing in recent weeks I found this is not sufficient in RHEL 7.4 and EINVAL is still returned during the devpts mount. In my initial testing of this branch under Fedora 26, with a newer kernel, I did not have this issue. It appears the older RHEL7 kernel devpts implementation requires that you be UID0/root in the namespace to mount (even without gid passed), which isn't the case during singularity mounts when user namespaces are being used. With newer kernels, this isn't an issue, but I can't think of an simple solution for #857 for RHEL 7.4. I'm currently testing a new branch which doesn't pass "gid=" to the mount when setuid is disabled, but will also not error out on RHEL7.4. |
Hi @hollowec , thanks for your reply!
That sounds like the best way to go in this case. It's still a bit strange, since looking through: |
My guess is that it's either: My interpretation of the second So in short, for CentOS 7.4 things might work only if the user's uid / gid is mapped to 0 / 0 inside the container. |
Yes, I think you're correct... it's likely the second kernel commit you mentioned that resolves the issue. I'll continue testing, and will try to submit a PR sometime next week. |
I've submitted PR #1196 as a potential fix for this. |
@hollowec This looks good (did not have time to test yet)! Do you think it's a good idea to add support to map of the uid / gid of the user starting singularity to another uid / gid in the user namespace, for example to 0 / 0, as charliecloud supports? |
Hi @hollowec , I just tested with a build from current
So at least, it looks like
|
Hi @olifre, Yes, I noticed that for some reason with the current development branch I have to pass '-u' (or '-f') in order to use user namespaces (even with "allow setuid = no" configured). I'm not sure if that's intentional, or a bug, but it's unrelated to my PR. |
Hi @hollowec ,
So we can see that In any case, your PR works very well for me and uses the correct approach in all those combinations ;-). |
OK, sounds good. If you plan on using OpenSSH sshd with this PR with setuid disabled (as discussed in #857), as you mentioned, the sshd code will also have to be modified to not care about pts device group ownership (like xterm). |
Yes, I know - I'm sadly not sure the OpenSSH people will be very open to such a suggestion. I have opened the RedHat bug report asking for backporting the kernel fix here: |
I am looping in @cclerget as he has been doing a massive overhaul on the development branch including implementing Linux capabilities to limit security escalation potential. |
I've opened a bug report on OpenSSH bugzilla about this: |
The use-case of running an ssh server without modification should now be supported via |
Version of Singularity:
2.4
Expected behavior
devpts is mounted also in unprivileged, user namespace mode.
Actual behavior
Silently fails.
Steps to reproduce behavior
Start any container, have
set.
This issue exists since #944 .
The more correct fix would have been to actually analyze why it's failing. Sadly, that has not been done (lack of QA), but a silent deactivation of the feature was implemented.
A simple analysis reveals the reason is the
gid=5
parameter used in thedevpts
mount (while the5
is resolved from thetty
gid):https://github.com/singularityware/singularity/blob/f2d7795d04bad5af371c3a4a0a6f372ba07ff810/src/lib/runtime/mounts/dev/dev.c#L114
Naturally, this is usually wanted, but can't work in user namespace containers, unless the tty-gid is mapped. Otherwise,
EINVALID
will be received.This has already been discussed a few years ago for more full-fledged container solutions:
opencontainers/runc#225
So it would be better to:
gid=5
from the mount parameters if user namespaces are used. This will not help for programms actually checking ownership of the devices (but one may argue that's a somewhat backwards idea anyways, since programs should rather check effective permissions), but at least makesdevpts
mounts work again.tty
group by mapping the user's group to it). This should help for most programs doing such ownership checks, but of course may look awkward to the users.Pinging @hollowec , who initially (thankfully) implemented
devpts
mounting, @gmkurtzer who merged the workaround silencing the actual error, and @DrDaveD who is interested in the topic (and implemented the workaround - I don't blame him for that, but I'd rather have expected a proper problem analysis by the core team before merging a silencing of an error).I'd also like to point out it's kind of bad that the failure discussed in #944 was actually not discovered by the test suite.
The text was updated successfully, but these errors were encountered: