* netlink and user namespaces
@ 2015-05-29 12:18 Alexander Larsson
[not found] ` <1432901907.7545.30.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-29 16:14 ` Eric W. Biederman
0 siblings, 2 replies; 3+ messages in thread
From: Alexander Larsson @ 2015-05-29 12:18 UTC (permalink / raw)
To: Linux Containers
Now that I'm using a non-privileged user namespace for my desktop
sandboxing system all kind of network status things are breaking. The
reason for this is that they use netlink to enumerated interfaces, and
to verify that the replies are from the kernel (apparently anyone can
send anyone netlink messages) this code is verifying that the
SCM_CREDENTIAL sender of the netlink messages is uid 0.
For instance:
http://git.0pointer.net/avahi.git/commit/avahi-core/netlink.c?id=37b2be93e63ceff95698f24cd91cb11774eb621c
and:
https://git.gnome.org/browse/glib/tree/gio/gnetworkmonitornetlink.c#n340
This obviously breaks when uid is not mapped (as it can't be in an
unprivileged user namespace), as uid will be overflowuid.
Is there any other way to check that a netlink message is from the
kernel?
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc
alexl-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org alexander.larsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
He's an uncontrollable skateboarding farmboy trapped in a world he never
made. She's a strong-willed renegade schoolgirl married to the Mob. They
fight crime!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: netlink and user namespaces
[not found] ` <1432901907.7545.30.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-05-29 16:14 ` Eric W. Biederman
0 siblings, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2015-05-29 16:14 UTC (permalink / raw)
To: Alexander Larsson; +Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Linux Containers
Alexander Larsson <alexl-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> Now that I'm using a non-privileged user namespace for my desktop
> sandboxing system all kind of network status things are breaking. The
> reason for this is that they use netlink to enumerated interfaces, and
> to verify that the replies are from the kernel (apparently anyone can
> send anyone netlink messages) this code is verifying that the
> SCM_CREDENTIAL sender of the netlink messages is uid 0.
>
> For instance:
> http://git.0pointer.net/avahi.git/commit/avahi-core/netlink.c?id=37b2be93e63ceff95698f24cd91cb11774eb621c
> and:
> https://git.gnome.org/browse/glib/tree/gio/gnetworkmonitornetlink.c#n340
>
> This obviously breaks when uid is not mapped (as it can't be in an
> unprivileged user namespace), as uid will be overflowuid.
>
> Is there any other way to check that a netlink message is from the
> kernel?
*scratches my head* Those are weird pieces of code.
The answer is the way you do this with any other socket.
Call recvfrom or recvmsg.
Looking at the senders address.
If in the senders address nl_pid == 0 then the message is from
the kernel. Otherwise the message is from userspace.
Looking anywhere else at anything else is bogus.
And a note. nl_pid is short for netlink port id. It is not a process id.
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: netlink and user namespaces
2015-05-29 12:18 netlink and user namespaces Alexander Larsson
[not found] ` <1432901907.7545.30.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-05-29 16:14 ` Eric W. Biederman
1 sibling, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2015-05-29 16:14 UTC (permalink / raw)
To: Alexander Larsson; +Cc: Linux Containers, netdev
Alexander Larsson <alexl@redhat.com> writes:
> Now that I'm using a non-privileged user namespace for my desktop
> sandboxing system all kind of network status things are breaking. The
> reason for this is that they use netlink to enumerated interfaces, and
> to verify that the replies are from the kernel (apparently anyone can
> send anyone netlink messages) this code is verifying that the
> SCM_CREDENTIAL sender of the netlink messages is uid 0.
>
> For instance:
> http://git.0pointer.net/avahi.git/commit/avahi-core/netlink.c?id=37b2be93e63ceff95698f24cd91cb11774eb621c
> and:
> https://git.gnome.org/browse/glib/tree/gio/gnetworkmonitornetlink.c#n340
>
> This obviously breaks when uid is not mapped (as it can't be in an
> unprivileged user namespace), as uid will be overflowuid.
>
> Is there any other way to check that a netlink message is from the
> kernel?
*scratches my head* Those are weird pieces of code.
The answer is the way you do this with any other socket.
Call recvfrom or recvmsg.
Looking at the senders address.
If in the senders address nl_pid == 0 then the message is from
the kernel. Otherwise the message is from userspace.
Looking anywhere else at anything else is bogus.
And a note. nl_pid is short for netlink port id. It is not a process id.
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-29 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 12:18 netlink and user namespaces Alexander Larsson
[not found] ` <1432901907.7545.30.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-29 16:14 ` Eric W. Biederman
2015-05-29 16:14 ` Eric W. Biederman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.