user_namespace.c 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License as
  4. * published by the Free Software Foundation, version 2 of the
  5. * License.
  6. */
  7. #include <linux/module.h>
  8. #include <linux/version.h>
  9. #include <linux/nsproxy.h>
  10. #include <linux/user_namespace.h>
  11. struct user_namespace init_user_ns = {
  12. .kref = {
  13. .refcount = ATOMIC_INIT(2),
  14. },
  15. .root_user = &root_user,
  16. };
  17. EXPORT_SYMBOL_GPL(init_user_ns);
  18. #ifdef CONFIG_USER_NS
  19. struct user_namespace * copy_user_ns(int flags, struct user_namespace *old_ns)
  20. {
  21. struct user_namespace *new_ns;
  22. BUG_ON(!old_ns);
  23. get_user_ns(old_ns);
  24. new_ns = old_ns;
  25. return new_ns;
  26. }
  27. void free_user_ns(struct kref *kref)
  28. {
  29. struct user_namespace *ns;
  30. ns = container_of(kref, struct user_namespace, kref);
  31. kfree(ns);
  32. }
  33. #endif /* CONFIG_USER_NS */