History

Merge tag 'namespaces-7.1-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull namespace update from Christian Brauner: "Add two simple helper macros for the namespace infrastructure" * tag 'namespaces-7.1-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: nsproxy: Add FOR_EACH_NS_TYPE() X-macro and CLONE_NS_ALL

Linus Torvalds committed 7 months ago

Commit dc0dfa72 parents fc825e5 935a0493 files · +41 −23Browse files

Showing the changes to kernel (2 of 3 files). Show all

Unified · Split

2 files
  1. kernel/fork.c +3 −4
  2. kernel/nsproxy.c +4 −9
kernel/fork.c+3−4
@@ -46,6 +46,7 @@ · 45 unmodified lines
4646 #include <linux/mm_inline.h>
4747 #include <linux/memblock.h>
4848 #include <linux/nsproxy.h>
49+#include <linux/ns/ns_common_types.h>
4950 #include <linux/capability.h>
5051 #include <linux/cpu.h>
5152 #include <linux/cgroup.h>
@@ -3045,11 +3046,9 @@ void __init proc_caches_init(void) · 2993 unmodified lines
30453046 */
30463047 static int check_unshare_flags(unsigned long unshare_flags)
30473048 {
3048− if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_NEWNS|CLONE_SIGHAND|
3049+ if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_SIGHAND|
30493050 CLONE_VM|CLONE_FILES|CLONE_SYSVSEM|
3050− CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET|
3051− CLONE_NEWUSER|CLONE_NEWPID|CLONE_NEWCGROUP|
3052− CLONE_NEWTIME))
3051+ CLONE_NS_ALL))
30533052 return -EINVAL;
30543053 /*
30553054 * Not implemented, but pretend it works if there is nothing
kernel/nsproxy.c+4−9
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/slab.h>
1313 #include <linux/export.h>
1414 #include <linux/nsproxy.h>
15+#include <linux/ns/ns_common_types.h>
1516 #include <linux/init_task.h>
1617 #include <linux/mnt_namespace.h>
1718 #include <linux/utsname.h>
@@ -170,9 +171,7 @@ int copy_namespaces(u64 flags, struct task_struct *tsk) · 152 unmodified lines
170171 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
171172 struct nsproxy *new_ns;
172173
173− if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
174− CLONE_NEWPID | CLONE_NEWNET |
175− CLONE_NEWCGROUP | CLONE_NEWTIME)))) {
174+ if (likely(!(flags & (CLONE_NS_ALL & ~CLONE_NEWUSER)))) {
176175 if ((flags & CLONE_VM) ||
177176 likely(old_ns->time_ns_for_children == old_ns->time_ns)) {
178177 get_nsproxy(old_ns);
@@ -214,9 +213,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags, · 35 unmodified lines
214213 struct user_namespace *user_ns;
215214 int err = 0;
216215
217− if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
218− CLONE_NEWNET | CLONE_NEWPID | CLONE_NEWCGROUP |
219− CLONE_NEWTIME)))
216+ if (!(unshare_flags & (CLONE_NS_ALL & ~CLONE_NEWUSER)))
220217 return 0;
221218
222219 user_ns = new_cred ? new_cred->user_ns : current_user_ns();
@@ -292,9 +289,7 @@ int exec_task_namespaces(void) · 69 unmodified lines
292289
293290 static int check_setns_flags(unsigned long flags)
294291 {
295− if (!flags || (flags & ~(CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
296− CLONE_NEWNET | CLONE_NEWTIME | CLONE_NEWUSER |
297− CLONE_NEWPID | CLONE_NEWCGROUP)))
292+ if (!flags || (flags & ~CLONE_NS_ALL))
298293 return -EINVAL;
299294
300295 #ifndef CONFIG_USER_NS