-
Notifications
You must be signed in to change notification settings - Fork 2.3k
don't relabel mqueue with user ns and make selinux and user ns can be used at the same time #731
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
Conversation
Signed-off-by: yangshukui <yangshukui@huawei.com>
|
@rhatdan PTAL |
|
What is the error that is blocking the relabel. Relabel should not be governed via DAC permissions. |
|
@runcom Have you seen this problem? |
After mount,mqueue、proc、sysfs dir ’s uid and gid are 65534,I don't know whether it is ok,but relabel failed in kuid_has_mapping.Can mqueue、proc、sysfs be the same and not be relabeled ? |
|
/proc ad sysfs are fine, but mqueue has a bad label by default. If you turn off labeling just for mqueue, what label does it get? tmpfs_t? Inside the container ls -lZd /dev/mueue kuid_has_mapping? Is this a kernel call? |
|
mqueue get a user_tmpfs_t label by default, why mqueue has a bad label ,can we modify the default label for mqueue? |
|
And why does kuid_has_mapping block? |
|
after mount , /dev/mqueue' s uid is 65534 in user ns, not 0 which the general file(e.g. /home) get,I think it's the reason. So if docker relabel proc(sysfs), it will fail as well. |
|
Right that is the bug if /dev/mqueue is not followin user namespace, its UID should not be -1 it should be the dockerroot uid inside of the container. Docker is setting the SELinux label, and I believe docker is running as UID=0, so it not being able to set the label is curious. If you disable SELinux inside the container, can the UID=dockerroot inside of the container create content in /dev/mqueu? |
|
@rhatdan ,thanks. do you means dockerroot is the root inside of the container ? use user ns and disable SELinux, the root inside of the container can't create content in /dev/mqueu. |
|
Exactly. The problem here, I believe is in the kernel, or docker in that /dev/mqueue is not being owned by dockerroot, docker should be changing the ownership of the /dev/mqueue to dockerroot, and changing the SELinux label. If this happens after usernamespace has been changed then the processes will not be allowed to write to /dev/mqueueu. |
Never seen this, also I don't understand what the error is 😕 The only thing I remember with selinux and userns is this BZ https://bugzilla.redhat.com/show_bug.cgi?id=1312665 which is said to be fixed upstream here in runc |
|
I'll look into this on Monday Sent from my iPhone
|
|
I tried to reproduce this on docker master and looks like it is broken with selinux on Fedora 23. |
|
No not related. What does ausearch -m avc -ts recent show? |
|
|
Did you set the mountlabel? |
|
Looks like the rootfs is labeled correctly |
|
But what does /dev inside the container look like? |
|
@rhatdan I can't access /dev from inside the container. |
|
Do you have the mountlabel defined in the containers json? If you executed setenforce 0 on the host you would be able to see the /dev. And it would not have the correct labels. With runc, you need to specify the mountlabel, so that it will setup any internal tmpfs based mount points with the correct labels. The label on the image rootfs has to be set outside of runc. |
|
@rhatdan This is with docker not runc hence it seems like a regression to me. |
|
Yes if this is docker, then it is a regression. |
|
@rhatdan We are missing context= in the mounts as you suspected. I am looking into a fix. |
|
MountLabel support is missing in the spec. I have created a PR for it here opencontainers/runtime-spec#393 |
after mount mqueue with user namespace,we will have a view like the following:
we can see the uid is 65534,this make sys_lsetxattr fail when kernel has a kuid_has_mapping check,so that we can't start a container with selinux and user ns at the same time.
proc and sys also have 65534 uid after mount ,and they are not relabeled.So we can remove the relabel for mqueue,If so, selinux and user ns can be used at the same time.
Signed-off-by: yangshukui yangshukui@huawei.com