From: ebiederm@xmission.com (Eric W. Biederman)
To: Alexander Larsson <alexl@redhat.com>
Cc: Linux Containers <containers@lists.linux-foundation.org>
Cc: <netdev@vger.kernel.org>
Subject: Re: netlink and user namespaces
Date: Fri, 29 May 2015 11:14:11 -0500 [thread overview]
Message-ID: <87vbfb4azw.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1432901907.7545.30.camel@redhat.com> (Alexander Larsson's message of "Fri, 29 May 2015 14:18:27 +0200")
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
prev parent reply other threads:[~2015-05-29 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbfb4azw.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=alexl@redhat.com \
--cc=containers@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.