ZFS is confused by user namespaces (uid/gid mapping) when used with acltype=posixac
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Fix Released
|
Undecided
|
Tim Gardner | ||
Xenial |
Fix Released
|
Undecided
|
Tim Gardner | ||
Yakkety |
Fix Released
|
Undecided
|
Tim Gardner | ||
zfs-linux (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Confirmed
|
Undecided
|
Unassigned | ||
Yakkety |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
This report is copy/paste from the following upstream issue: https:/
I was asked to file a matching Ubuntu bug for tracking.
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)
root@dakara:~# zfs create lxd/test -o mountpoint=
root@dakara:~# zfs set acltype=posixacl lxd/test
root@dakara:~# cd /tmp/test/
root@dakara:
root@dakara:
root@dakara:
root@dakara:
# file: a
# owner: root
# group: root
user::rwx
user:100100:rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:
default:group::r-x
default:mask::rwx
default:other::r-x
root@dakara:
root@dakara:
total 512
drwxrwxr-x+ 2 nobody nogroup 2 Jan 7 22:19 a
root@dakara:
# file: a
# owner: nobody
# group: nogroup
user::rwx
user:4294967295:rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:
default:group::r-x
default:mask::rwx
default:other::r-x
# Example with ext4 (working)
root@dakara:
root@dakara:
root@dakara:
root@dakara:
# file: a
# owner: root
# group: root
user::rwx
user:100100:rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:
default:group::r-x
default:mask::rwx
default:other::r-x
root@dakara:
root@dakara:
total 4.0K
drwxrwxr-x+ 2 nobody nogroup 4.0K Jan 7 22:22 a
root@dakara:
# file: a
# owner: 65534
# group: 65534
user::rwx
user:100:rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:
default:group::r-x
default:mask::rwx
default:other::r-x
# 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 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(
You could reproduce something similar using the simple unshare tool and manual writes to /proc/PID/
Changed in linux (Ubuntu): | |
status: | New → Confirmed |
Changed in zfs-linux (Ubuntu): | |
status: | New → Confirmed |
Changed in linux (Ubuntu Xenial): | |
assignee: | nobody → Tim Gardner (timg-tpi) |
status: | New → In Progress |
Changed in linux (Ubuntu Yakkety): | |
assignee: | nobody → Tim Gardner (timg-tpi) |
status: | Confirmed → Fix Committed |
Changed in linux (Ubuntu Xenial): | |
status: | In Progress → Fix Committed |
This is fixed upstream: /github. com/zfsonlinux/ zfs/commit/ 874bd959f4f15b3 d4b007160ee7ad3 f4111dd341
https:/