Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 509728 - SELinux policy prevents dns from working when network manager uses openresolv
Summary: SELinux policy prevents dns from working when network manager uses openresolv
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard: sec-policy r4
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-06 20:04 UTC by Jason Zaman
Modified: 2014-08-22 17:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
resolvconf.te (type enforcement settings) plus other domain calls (resolvconf.te,1.22 KB, text/plain)
2014-06-23 20:16 UTC, Sven Vermeulen (RETIRED)
Details
resolvconf.if (interface definitions) (resolvconf.if,1.10 KB, text/x-matlab)
2014-06-23 20:17 UTC, Sven Vermeulen (RETIRED)
Details
resolvconf.fc (file context definitions) (resolvconf.fc,214 bytes, text/plain)
2014-06-23 20:18 UTC, Sven Vermeulen (RETIRED)
Details
resolvconf.if (interface definitions) (resolvconf.if,2.27 KB, text/x-matlab)
2014-06-25 19:29 UTC, Sven Vermeulen (RETIRED)
Details
resolvconf.te (type enforcement settings) plus other domain calls (resolvconf.te,1.23 KB, text/plain)
2014-06-25 19:29 UTC, Sven Vermeulen (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Zaman gentoo-dev 2014-05-06 20:04:02 UTC
net-dns/openresolv is a tool that manages /etc/resolv.conf when many
different things try and add dns servers. NetworkManager starts properly
and gets and IP address but nothing gets written to /etc/resolv.conf

i needed to add the following labels because its original label was not
allowed write access to /etc/resolv.conf:

/sbin/resolvconf -- system_u:object_r:NetworkManager_exec_t
/var/run/resolvconf(/.*)?    system_u:object_r:NetworkManager_var_run_t

I am not sure if something like resolvconf should have its own domain
since it can be called from many places but it seems to work when I used
the NetworkManager domain and things like wpa_supplicant are labelled as
NetworkManager to also.


Reproducible: Always

Steps to Reproduce:
1. enable the "resolvconf" USE-flag
2. emerge net-misc/networkmanager and it will also pull in net-dns/openresolv
3. start network manager and connect to a network
4. ping 8.8.8.8
5. ping google.com
Actual Results:  
step 5 fails with host not found.

Expected Results:  
both pings should succeed.
Comment 1 Sven Vermeulen (RETIRED) gentoo-dev 2014-05-19 17:23:40 UTC
When /sbin/resolvconf is "just" bin_t (assuming that it's label), did you get any failures from NetworkManager trying to execute it? NetworkManager_t has execute rights on shells and binaries, so this shouldn't give any issue(s).

The /var/run/resolvconf(/.*)? one might be the culprit. What is this location used for by resolvconf? 

If it is directly used by resolvconf, then either we need to create a specific domain for resolvconf (and allow it to manage that location) or use a type that all network management domains can write to (which will not be easy to find).
Comment 2 Jason Zaman gentoo-dev 2014-05-19 17:49:42 UTC
> The /var/run/resolvconf(/.*)? one might be the culprit. What is this
> location used for by resolvconf? 

basically the way resolvconf is used by different things (eg wifi and vpn):
echo "nameserver 8.8.8.8" | resolvconf -a wlan0

then later you turn on the vpn and you get something like:
echo "nameserver 192.168.1.1" | resolvconf -a tun0

it uses all the information to build /etc/resolv.conf, later when tun0 is taken down it still knows about the previous dns servers so you dont end up with an empty resolv.conf.

in this case you get the following files (among a couple other minor things):
/var/run/resolvconf/interfaces/{wlan0,tun0}
nothing else needs to be able to access those files only resolvconf.

Ideally I think a new label is the best but I did notice that things like wpa_supplicant were labelled with NetworkManager_exec_t too so I thought perhaps that was the standard way to label things.
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-23 20:16:51 UTC
Created attachment 379512 [details]
resolvconf.te (type enforcement settings) plus other domain calls

Type enforcement module for openresolv. It currently calls dhcpc_t directly as a matter of testing, but I will make the policy support resolvconf_client attributes instead later (after more testing).
Comment 4 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-23 20:17:42 UTC
Created attachment 379514 [details]
resolvconf.if (interface definitions)

Interface definitions to be exported.

Still needs to be enhanced with a resolvconf_client() and resolvconf_client_perms() method
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-23 20:18:07 UTC
Created attachment 379516 [details]
resolvconf.fc (file context definitions)

File context definitions for openresolv.
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-23 20:20:34 UTC
The attached files are just an intermediate result of some light policy development. I still need to do further testing and validation, and make a proper client domain so that clients can just call "openresolv_client(mydomain_t)" or "openresolv_client_perms(mydomain_t)" instead of having the various interfaces called.

Also, users running "resolvconf -l" or "resolvconf -u" is currently not supported yet (the application in the current policy is only allowed to be called by the clients) which also needs to happen.

Minor changes, but it's late here so just informing you guys about the progress.
Comment 7 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-25 19:29:21 UTC
Created attachment 379662 [details]
resolvconf.if (interface definitions)

Updated interface.

Important ones to consider:

resolvconf_client_domain() to assign to the services that will call resolvconf. For instance:

  resolvconf_client_domain(dhcpc_t)

There is also a resolvconf_client_domain_privs() in case you need to selectively apply this (within a tunable_policy statement).

resolvconf_exec() to assign to the user domain. It allows the user to execute resolvconf (without transition). I'm not sure if we need to have a resolvconf_role() for now, but we can add that in later.
Comment 8 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-25 19:29:43 UTC
Created attachment 379664 [details]
resolvconf.te (type enforcement settings) plus other domain calls

Updated .te file, now includes resolvconf_client attribute.
Comment 9 Sven Vermeulen (RETIRED) gentoo-dev 2014-06-25 20:03:21 UTC
Policy is in live repository, sec-policy/selinux-resolvconf package is available.

Support in networkmanager and dhcpc_t is also added to the policy (you'll need to rebuild selinux-base and selinux-base-policy first before selinux-networkmanager).
Comment 10 Sven Vermeulen (RETIRED) gentoo-dev 2014-08-01 21:11:37 UTC
r4 is in the tree
Comment 11 Sven Vermeulen (RETIRED) gentoo-dev 2014-08-22 17:50:26 UTC
r5 is stable