-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ZFS is confused by user namespaces (uid/gid mapping) when used with acltype=posixacl #4177
Comments
The lxc-usernsexec helper tool I'm using there comes from the LXC package in Ubuntu. It essentially causes a call to fork() followed by a call to unshare(CLONE_NEWUSER), then calls the newuidmap and newgidmap setuid helpers with the provided map so that the namespace can be configured properly. You could reproduce something similar using the simple unshare tool and manual writes to /proc/PID/{u,g}id_map |
@stgraber nice to meet you, thanks for the clear bug report and sorry about the slow reply. It looks to me like for some reason ZFS wasn't able to find a valid mapping in the namespace for the uid. We'll need to spend some time digging to determine exactly why, but with a test case that should be pretty straight forward once a developer has time to look in to it. My suspicion is that it will be something fairly simple once identified. The kernel doesn't expect much from the filesystem to support namespaces, largely just the hooks to to save and restore xattrs. Most of the complexity here comes from the fact that the kernel interfaces change fairly frequently and we need to support several of them concurrently. |
I ran in to this problem on ubuntu 16.04 today. I'm using posix acls on zfs with my lxc containers. Now I have a bunch on non-important files and directories that I can't delete or access. root@hostname:/mnt/storage/media/Movies/Movie)# rm -rf extra* root@hostname:/mnt/storage/media/Movies/Movie# cd extrathumbs/ Is there any way to clean this up? |
@kpeterson11 - I have run into this exact ( |
I have managed to clean up the bad files. I had to log in to the container, become the user that owned the files, try to delete the file and get a "permission denied error", switch to my other console with the root user on the host and successfully delete the file. I think the trick was to access the affected files using the user in the container. Using cat on the file as the owner in the container worked too. For now, I've changed the container to privileged and set acls using the actual uid of the user in the container. Hopefully things behave now. If not, I'll have to go back to freenas. It seems I'm not having much luck with these acls. |
My two cents at this: torvalds/linux@5f3a4a2 introduced the user_ns parameter, and the commit is quite clear - that CRED()->user_ns linked before should refer to init_user_ns (http://lxr.free-electrons.com/source/kernel/user.c?v=4.4#L25) ....which is... EXPORT_SYMBOL_GPL . :( |
As described in torvalds/linux@5f3a4a2 the &init_user_ns, and not the current user_ns, should be passed to posix_acl_from_xattr() and posix_acl_to_xattr(). Conveniently the init_user_ns is available through the init credential (kcred). Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue openzfs#4177
@maxximino nice job running down the root cause. I've proposed #4576 which provides |
As described in torvalds/linux@5f3a4a2 the &init_user_ns, and not the current user_ns, should be passed to posix_acl_from_xattr() and posix_acl_to_xattr(). Conveniently the init_user_ns is available through the init credential (kcred). Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue openzfs#4177
As described in torvalds/linux@5f3a4a2 the &init_user_ns, and not the current user_ns, should be passed to posix_acl_from_xattr() and posix_acl_to_xattr(). Conveniently the init_user_ns is available through the init credential (kcred). Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Massimo Maggi <me@massimo-maggi.eu> Closes openzfs#4177
Hello,
First a quick introduction to the world of containers
I'm the project leader for LXC and LXD, working on containers on Linux. We now extensively use the user namespaces to provide an extra layer of security in Linux containers.
The user namespace allows one to map a range of uid and gid from the host or parent namespace into another range of uid and gid of a new namespace.
Typically what's done is that 65536 uids and gids are set aside per non-system users on the host. Those users through a couple of setuid helpers (newuidmap and newgidmap) can then setup a uid and gid map for their processes. Their 65536 allocation is therefore mapped from uid/gid 0 to 65536 of the new namespace, providing a POSIX-compatible environment.
That means that given a user on the host with uid and gid range 100000 through 165536, uid 100 in their container will be mapped to uid 100100 outside of it.
The problem with ZFS
When using ZFS with acltype=posixacl and an ACL entry on the host set for a uid (or gid) that's then mapped into the container, the container doesn't see the right mapped value when querying the acl from inside the namespace.
Example with zfs (broken)
Example with ext4 (working)
Environment
This was noticed on Ubuntu 14.04 using the zfs stable PPA. I first found it in production environments first with file servers misbehaving due to the problem, then reproduced it on my development systems.
The zfs version here is 0.6.5.3-1~trusty and I've seen this on 3.13, 3.16, 3.19 and 4.2 kernels (not that it should matter, the dkms code was the same). zfs-dkms is at 2.53-zfs1.
The text was updated successfully, but these errors were encountered: