Skip to content

User namespaces: introduction

Serge E. Hallyn containers 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10user namespaces: introduce user_struct->user_namespace relationshipinclude/linux/sched.h include/linux/user_namespace.h kernel/user.c +1 more+20 -90 replies
2/10user namespaces: move user_ns from nsproxy into user structinclude/linux/init_task.h include/linux/key.h include/linux/nsproxy.h +8 more+39 -790 replies
3/10user namespaces: reset task's credentials on CLONE_NEWUSERkernel/user_namespace.c+14 -00 replies
4/10user namespaces: enforce user namespaces for file permissionfs/namei.c fs/super.c include/linux/fs.h+83 -48 replies
5/10user namespaces: Allow registering new usernamespaces using mountfs/ext3/super.c fs/namespace.c include/linux/fs.h +2 more+256 -00 replies
6/10user namespaces: hook fs/attr.cfs/attr.c include/linux/sched.h+20 -90 replies
7/10user namespaces: bad bad bad but test codelib/fsuserns.c+9 -00 replies
8/10userns: store child userns uids as xattrs in ext3 using lib/fsusernsfs/ext3/namei.c fs/ext3/xattr.c fs/ext3/xattr.h +3 more+113 -10 replies
9/10userns: have ext3 use fsuserns to read userns xattrs, and add groups to usernsfs/ext3/super.c fs/ext3/xattr.c fs/ext3/xattr.h +2 more+71 -120 replies
10/10userns: add support for readdirfs/ext3/file.c fs/ext3/inode.c fs/ext3/namei.c +2 more+64 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [0/10] User namespaces: introduction

Hi Eric,

so here is a start to a userns patchset trying to follow your ideas about how to have user namespaces and filesystems interact. Ignore the bookkeeping crap or you'll pull your hair out. Lots of stuff remains unimplemented - i.e. chown (setattr) and proper handling of capabilities. But you can do some fun things with this patchset. I.e.

(log in as root)
setcap cap_sys_admin=ep ns_exec
setcap cap_sys_admin=ep usernsmount
ns_exec -U /bin/sh
ls /root (fails)
ls / (succeeds)
(log in as hallyn)
ns_exec -U /bin/sh
id
(uid=0, gid=0)
ls (fails, can't descend /home/hallyn) usernsmount / nsid=4
ls (succeeds)
touch ab
ls -l ab
(ab is owned by root)
exit
(we're logged in as hallyn in the init_user_ns again) ls -l ab
(ab is owned by hallyn)

The only supported fs is ext3. Only a few operations are supported. So if, above, when we are hallyn in the init_user_ns but root in the child user ns,

	when we create a file, it is properly handled, so
		inode->i_uid=500, but an xattr (nsid=4,uid=0) is added
	when we chown the file to root, it is not properly handled,
		so inode->i_uid = 0

it's just a matter of hooking all the places at this point.

Capabilities remain a problem. Right now I think capabilities will need to be split up into system-wide caps, and container-safe caps. So CAP_NET_ADMIN, CAP_NET_RAW, CAP_DAC_OVERRIDE, those are container-safe. CAP_REBOOT may become container-safe one day, but for now is very much system-wide.

So if I'm uid 500 on the host and create a user namespace where I'm uid=0, I should be able to acquire container-safe caps (perhaps contingent on whether I unshared all other namespaces), but not system-wide ones. Or, whether I can acquire them would depend on whether the suid bit was set in a user_ns or not. sigh.

thanks,
-serge