aboutsummaryrefslogtreecommitdiff
path: root/kernel/user_namespace.c
AgeCommit message (Collapse)AuthorFilesLines
2008-04-29eCryptfs: make key module subsystem respect namespacesMichael Halcrow1-0/+1
Make eCryptfs key module subsystem respect namespaces. Since I will be removing the netlink interface in a future patch, I just made changes to the netlink.c code so that it will not break the build. With my recent patches, the kernel module currently defaults to the device handle interface rather than the netlink interface. [[email protected]: export free_user_ns()] Signed-off-by: Michael Halcrow <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-04-29kernel: explicitly include required header files under kernel/Robert P. J. Day1-0/+1
Following an experimental deletion of the unnecessary directive #include <linux/slab.h> from the header file <linux/percpu.h>, these files under kernel/ were exposed as needing to include one of <linux/slab.h> or <linux/gfp.h>, so explicit includes were added where necessary. Signed-off-by: Robert P. J. Day <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-02-08namespaces: cleanup the code managed with the USER_NS optionPavel Emelyanov1-13/+0
Make the user_namespace.o compilation depend on this option and move the init_user_ns into user.c file to make the kernel compile and work without the namespaces support. This make the user namespace code be organized similar to other namespaces'. Also mask the USER_NS option as "depend on NAMESPACES". [[email protected]: coding-style fixes] Signed-off-by: Pavel Emelyanov <[email protected]> Acked-by: Serge Hallyn <[email protected]> Cc: Cedric Le Goater <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Herbert Poetzl <[email protected]> Cc: Kirill Korotaev <[email protected]> Cc: Sukadev Bhattiprolu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-09-19Fix user namespace exiting OOPsPavel Emelyanov1-1/+1
It turned out, that the user namespace is released during the do_exit() in exit_task_namespaces(), but the struct user_struct is released only during the put_task_struct(), i.e. MUCH later. On debug kernels with poisoned slabs this will cause the oops in uid_hash_remove() because the head of the chain, which resides inside the struct user_namespace, will be already freed and poisoned. Since the uid hash itself is required only when someone can search it, i.e. when the namespace is alive, we can safely unhash all the user_struct-s from it during the namespace exiting. The subsequent free_uid() will complete the user_struct destruction. For example simple program #include <sched.h> char stack[2 * 1024 * 1024]; int f(void *foo) { return 0; } int main(void) { clone(f, stack + 1 * 1024 * 1024, 0x10000000, 0); return 0; } run on kernel with CONFIG_USER_NS turned on will oops the kernel immediately. This was spotted during OpenVZ kernel testing. Signed-off-by: Pavel Emelyanov <[email protected]> Signed-off-by: Alexey Dobriyan <[email protected]> Acked-by: "Serge E. Hallyn" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-09-19Convert uid hash to hlistPavel Emelyanov1-1/+1
Surprisingly, but (spotted by Alexey Dobriyan) the uid hash still uses list_heads, thus occupying twice as much place as it could. Convert it to hlist_heads. Signed-off-by: Pavel Emelyanov <[email protected]> Signed-off-by: Alexey Dobriyan <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-08-31userns: don't leak root userAlexey Dobriyan1-0/+1
Signed-off-by: Alexey Dobriyan <[email protected]> Acked-by: Cedric Le Goater <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-07-16fix create_new_namespaces() return valueCedric Le Goater1-3/+3
dup_mnt_ns() and clone_uts_ns() return NULL on failure. This is wrong, create_new_namespaces() uses ERR_PTR() to catch an error. This means that the subsequent create_new_namespaces() will hit BUG_ON() in copy_mnt_ns() or copy_utsname(). Modify create_new_namespaces() to also use the errors returned by the copy_*_ns routines and not to systematically return ENOMEM. [[email protected]: better changelog] Signed-off-by: Cedric Le Goater <[email protected]> Cc: Serge E. Hallyn <[email protected]> Cc: Badari Pulavarty <[email protected]> Cc: Pavel Emelianov <[email protected]> Cc: Herbert Poetzl <[email protected]> Cc: Eric W. Biederman <[email protected]> Cc: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-07-16user namespace: add unshareSerge E. Hallyn1-1/+45
This patch enables the unshare of user namespaces. It adds a new clone flag CLONE_NEWUSER and implements copy_user_ns() which resets the current user_struct and adds a new root user (uid == 0) For now, unsharing the user namespace allows a process to reset its user_struct accounting and uid 0 in the new user namespace should be contained using appropriate means, for instance selinux The plan, when the full support is complete (all uid checks covered), is to keep the original user's rights in the original namespace, and let a process become uid 0 in the new namespace, with full capabilities to the new namespace. Signed-off-by: Serge E. Hallyn <[email protected]> Signed-off-by: Cedric Le Goater <[email protected]> Acked-by: Pavel Emelianov <[email protected]> Cc: Herbert Poetzl <[email protected]> Cc: Kirill Korotaev <[email protected]> Cc: Eric W. Biederman <[email protected]> Cc: Chris Wright <[email protected]> Cc: Stephen Smalley <[email protected]> Cc: James Morris <[email protected]> Cc: Andrew Morgan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-07-16user namespace: add the frameworkCedric Le Goater1-0/+43
Basically, it will allow a process to unshare its user_struct table, resetting at the same time its own user_struct and all the associated accounting. A new root user (uid == 0) is added to the user namespace upon creation. Such root users have full privileges and it seems that theses privileges should be controlled through some means (process capabilities ?) The unshare is not included in this patch. Changes since [try #4]: - Updated get_user_ns and put_user_ns to accept NULL, and get_user_ns to return the namespace. Changes since [try #3]: - moved struct user_namespace to files user_namespace.{c,h} Changes since [try #2]: - removed struct user_namespace* argument from find_user() Changes since [try #1]: - removed struct user_namespace* argument from find_user() - added a root_user per user namespace Signed-off-by: Cedric Le Goater <[email protected]> Signed-off-by: Serge E. Hallyn <[email protected]> Acked-by: Pavel Emelianov <[email protected]> Cc: Herbert Poetzl <[email protected]> Cc: Kirill Korotaev <[email protected]> Cc: Eric W. Biederman <[email protected]> Cc: Chris Wright <[email protected]> Cc: Stephen Smalley <[email protected]> Cc: James Morris <[email protected]> Cc: Andrew Morgan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>