Message ID | 20210124225849.659106-1-eichest@gmail.com |
---|---|
State | Accepted |
Delegated to: | John Crispin |
Headers | show |
Series | [procd] hotplug.c: set nl_pid to zero | expand |
On 24.01.21 23:58, eichest@gmail.com wrote: > From: Stefan Eichenberger <eichest@gmail.com> > > With the current solution where nl_pid is set through getpid we run into > problems when running procd in a different PID namespace (e.g. > container). The PID number inside the active PID namespace will be set > which doesn't match the global PID. Therefore, procd will never receive > any netlink messages. > > By setting nl_pid to zero the kernel will assign the global PID > automatically and fixes the issue. > > Signed-off-by: Stefan Eichenberger <eichest@gmail.com> > --- > plug/hotplug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/plug/hotplug.c b/plug/hotplug.c > index 9aeb1c1..beff38a 100644 > --- a/plug/hotplug.c > +++ b/plug/hotplug.c > @@ -612,7 +612,7 @@ void hotplug(char *rules) > > rule_file = strdup(rules); > nls.nl_family = AF_NETLINK; > - nls.nl_pid = getpid(); > + nls.nl_pid = 0; > nls.nl_groups = -1; > > if ((hotplug_fd.fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT)) == -1) { Acked-by: John Crispin <john@phrozen.org> Just tested this locally outside a pid namespace.
diff --git a/plug/hotplug.c b/plug/hotplug.c index 9aeb1c1..beff38a 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -612,7 +612,7 @@ void hotplug(char *rules) rule_file = strdup(rules); nls.nl_family = AF_NETLINK; - nls.nl_pid = getpid(); + nls.nl_pid = 0; nls.nl_groups = -1; if ((hotplug_fd.fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT)) == -1) {