Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: mediate netlink sockets via seccomp #2969
Conversation
jdstrand
added some commits
Feb 17, 2017
jdstrand
closed this
Mar 1, 2017
jdstrand
changed the title from
Netlink mediation
to
interfaces: mediate netlink sockets via seccomp
Mar 1, 2017
|
Creating a PR for others to see (but closing it since it needs iterating). |
|
@morphis - can you also take a look at this? |
jdstrand
reopened this
Mar 2, 2017
jdstrand
added some commits
Mar 2, 2017
|
@tyhicks - can you also take a look at this? I'm wondering if I should create additional interfaces or even a 'netlink-socket' interface with 'socket AF_NETLINK' as an escape hatch since I observed that some uses of AF_NETLINK don't go through the LSM. Eg, java server running as root triggered a NETLINK_ROUTE seccomp denial but not an AppArmor 'network netlink' denial. I then saw net/netlink/af_netlink.c and thought this might be because the LSM hooks aren't triggered under certain circumstances (eg, netlink_sendmsg() if not root), but didn't chase down NETLINK_ROUTE. I then went codesearched the various NETLINK_* families and sprinkled them in various places (eg, cadvisor is a docker tool and needs NETLINK_GENERIC, ibacm is an infiniband tool and needs NETLINK_RDMA, etc). Results:
Looking at this, I think I should add 'netlink-audit' and 'netlink-connector' interfaces that allow |
|
The travis-ci issues are real. AF_MPLS, PF_MLPS, AF_IB and PF_IB don't exist on trusty. |
jdstrand
added some commits
Mar 2, 2017
|
Per discussions with @tyhicks, added netlink-audit and netlink-connector. |
|
On 03/02/2017 12:03 PM, jdstrand wrote:
@tyhicks <https://github.com/tyhicks> - can you also take a look at
this?
FTR, I spoke with @jdstrand about this over IRC and gave him a +1 on his
approach.
|
|
"since I observed that some uses of AF_NETLINK don't go through the LSM. Eg, java server running as root triggered a NETLINK_ROUTE seccomp denial but not an AppArmor 'network netlink' denial" @tyhicks and I looked at this more and it seems that what I observed was related to kernel rate limiting (even though I had it disabled). I think it is fine to keep the NETLINK_ROUTE in network-bind for the moment though. In fact, we have a note about intentionally not allowing 'network netlink dgram' in network-bind for java servers because they work fine without it. If we leave out the NETLINK_ROUTE seccomp rule, this previously known harmless denial will turn into a seccomp KILL. Once seccomp errno with logging is finished, we can remove this rule. |
jdstrand
added some commits
Mar 3, 2017
|
Just FYI, this cannot land unless we run snap-confine from the core snap. |
niemeyer
added
the
Blocked
label
Mar 13, 2017
jdstrand
and others
added some commits
Mar 29, 2017
|
This failed on networking/ssl:
|
zyga
removed
the
Blocked
label
Apr 14, 2017
|
This is no longer blocked, we should re-introduce all the new features to snap-confine, that were removed when reexec was a problem. |
|
It is my understanding that this is now unblocked, so removing that tag, but closing until I have a chance to review and retest everything. |
jdstrand
closed this
Apr 17, 2017
|
Since I'm told that snap-confine now re-exec's as needed, reopening. |
jdstrand
reopened this
Apr 18, 2017
jdstrand
and others
added some commits
Apr 18, 2017
jdstrand
added some commits
May 3, 2017
zyga
approved these changes
May 3, 2017
Looks good, builds on Ubuntu, Debian and Fedora.
+1
| + sc_map_add(AF_NFC); | ||
| + sc_map_add(PF_NFC); | ||
| + sc_map_add(AF_VSOCK); | ||
| + sc_map_add(PF_VSOCK); |
zyga
May 3, 2017
Contributor
Wow, that's quite the list. Reading about them is pretty interesting in itself!
| + sc_map_add(NETLINK_ECRYPTFS); | ||
| + sc_map_add(NETLINK_RDMA); | ||
| + sc_map_add(NETLINK_CRYPTO); | ||
| + sc_map_add(NETLINK_INET_DIAG); // synonymous with NETLINK_SOCK_DIAG |
chipaca
merged commit 1abdf4b
into
snapcore:master
May 3, 2017
7 checks passed
|
Code looks fine and I am fine with landing this. We run a full weekly CI cycle against beta/edge core snaps so merging this early enough before the next release should give us confidence if this breaks something or not. |
|
Thanks for all the reviews, comments and merge! :) |
jdstrand commentedMar 1, 2017
•
Edited 1 time
-
jdstrand
Mar 2, 2017
AppArmor only has coarse-grained mediation for the
typefor netlink (man 7 netlink) sockets but it is useful to be able to mediate by the netlink_family as well. This branch achieves that by introducing support forsocket AF_NETLINK - NETLINK_*seccomp rules by:include/linux/socket.hfrom the kernel)We omit PF_* in the policy since those are synonymous with AF_*. We do not use 'socket !AF_NETLINK' in the default template because that doesn't work well with an interface that uses 'socket AF_NETLINK').
Importantly,
network netlinkAppArmor rules were not in the default policy or most of the interfaces and the changes to policy outside of the template are for permanent slot policy for slot implementations for those that had 'network netlink' rules (and modem-manager and bluez that were mistakenly missing them). We do allow NETLINK_ROUTE in network-bind but continue to disallow netlink rules there to avoid KILLing java servers which attempt it but otherwise fail gracefully.Since there are applications in codesearch.debian.net known to use NETLINK_AUDIT and NETLINK_CONNECTOR, add two new interfaces for them.
Testing performed:
While this PR is useful in and of itself because we can finely-mediate netlink sockets for our slot implementations, account-control, network-control and network-observe, this functionality is most important for adding NETLINK_KOBJECT_UEVENT for udev to x11/unity7 to support QtSystem applications on X. Since there is some conditional logic that is going to be introduced there, it will be in a separate PR.