Commit 5f71a29629b4717445f8b7f5fb8f50c2d262b68e

Authored by Eric W. Biederman
Committed by Greg Kroah-Hartman
1 parent 910a7e905f

kobj: Send hotplug events in the proper namespace.

Utilize netlink_broacast_filtered to allow sending hotplug events
in the proper namespace.

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 20 additions and 2 deletions Side-by-side Diff

lib/kobject_uevent.c
... ... @@ -83,6 +83,22 @@
83 83 return ret;
84 84 }
85 85  
  86 +static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data)
  87 +{
  88 + struct kobject *kobj = data;
  89 + const struct kobj_ns_type_operations *ops;
  90 +
  91 + ops = kobj_ns_ops(kobj);
  92 + if (ops) {
  93 + const void *sock_ns, *ns;
  94 + ns = kobj->ktype->namespace(kobj);
  95 + sock_ns = ops->netlink_ns(dsk);
  96 + return sock_ns != ns;
  97 + }
  98 +
  99 + return 0;
  100 +}
  101 +
86 102 /**
87 103 * kobject_uevent_env - send an uevent with environmental data
88 104 *
... ... @@ -244,8 +260,10 @@
244 260 }
245 261  
246 262 NETLINK_CB(skb).dst_group = 1;
247   - retval = netlink_broadcast(uevent_sock, skb, 0, 1,
248   - GFP_KERNEL);
  263 + retval = netlink_broadcast_filtered(uevent_sock, skb,
  264 + 0, 1, GFP_KERNEL,
  265 + kobj_bcast_filter,
  266 + kobj);
249 267 /* ENOBUFS should be handled in userspace */
250 268 if (retval == -ENOBUFS)
251 269 retval = 0;