Commit 417daa1e8f893fbac88fd395340ba7779fd3926c
Committed by
Greg Kroah-Hartman
1 parent
5f71a29629
Exists in
master
and in
39 other branches
hotplug: netns aware uevent_helper
It only makes sense for uevent_helper to get events in the intial namespaces. It's invocation is not per namespace and it is not clear how we could make it's invocation namespace aware. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 17 additions and 2 deletions Side-by-side Diff
lib/kobject_uevent.c
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | #include <linux/kobject.h> |
20 | 20 | #include <linux/module.h> |
21 | 21 | #include <linux/slab.h> |
22 | - | |
22 | +#include <linux/user_namespace.h> | |
23 | 23 | #include <linux/socket.h> |
24 | 24 | #include <linux/skbuff.h> |
25 | 25 | #include <linux/netlink.h> |
... | ... | @@ -99,6 +99,21 @@ |
99 | 99 | return 0; |
100 | 100 | } |
101 | 101 | |
102 | +static int kobj_usermode_filter(struct kobject *kobj) | |
103 | +{ | |
104 | + const struct kobj_ns_type_operations *ops; | |
105 | + | |
106 | + ops = kobj_ns_ops(kobj); | |
107 | + if (ops) { | |
108 | + const void *init_ns, *ns; | |
109 | + ns = kobj->ktype->namespace(kobj); | |
110 | + init_ns = ops->initial_ns(); | |
111 | + return ns != init_ns; | |
112 | + } | |
113 | + | |
114 | + return 0; | |
115 | +} | |
116 | + | |
102 | 117 | /** |
103 | 118 | * kobject_uevent_env - send an uevent with environmental data |
104 | 119 | * |
... | ... | @@ -274,7 +289,7 @@ |
274 | 289 | #endif |
275 | 290 | |
276 | 291 | /* call uevent_helper, usually only enabled during early boot */ |
277 | - if (uevent_helper[0]) { | |
292 | + if (uevent_helper[0] && !kobj_usermode_filter(kobj)) { | |
278 | 293 | char *argv [3]; |
279 | 294 | |
280 | 295 | argv [0] = uevent_helper; |