RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1286851 - ip netns exec needs more permissions
Summary: ip netns exec needs more permissions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.3
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-30 21:44 UTC by Aleksandar Kostadinov
Modified: 2023-09-14 03:14 UTC (History)
9 users (show)

Fixed In Version: selinux-policy-3.13.1-80.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 02:25:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2283 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2016-11-03 13:36:25 UTC

Description Aleksandar Kostadinov 2015-11-30 21:44:59 UTC
Description of problem:
Trying to run a systemd service that calls `ip netns exec`. That fails:

> type=AVC msg=audit(1448915156.934:10947070): avc:  denied  { mounton } for  pid=25632 comm="ip" path="/" dev="dm-1" ino=128 scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:root_t:s0 tclass=dir
> 	Was caused by:
> 		Missing type enforcement (TE) allow rule.

To see why mount is needed, see "exec" section of
> man ip-netns

I think that running a service under a network namespace is important as systems like OpenStack do stuff inside different namespaces and one may need to interact with them. Also systemd native netns support might be useful by a directive under [Service] but that's anothe thing.

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-23.el7_1.18.noarch

How reproducible:
always

Steps to Reproduce:
1. create a selinux service calling ip netns
2. start it
3. see audit log/audit2why --all

Actual results:
FAIL

Expected results:
ip netns works fine

Additional info:

temporary fix:
> chcon -t bin_t /usr/sbin/ip

Here's the service file I'm using:
[Unit]
Description=Redsocks transparent SOCKS proxy redirector
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/default/redsocks
ExecStartPre=/usr/sbin/redsocks -t -c /etc/redsocks.conf
ExecStart=/usr/sbin/ip netns exec mynetns /usr/sbin/redsocks -c /etc/redsocks.conf
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Comment 1 Aleksandar Kostadinov 2015-11-30 22:46:59 UTC
FYI, because the workaround will go away on `restorecon` or RPM upgrade, I've created a separate service type=simple, to execute `chcon ...`. I've added Requires=chcon.service under [Unit] section of my main service. Now upon running main service, systemd will first run my chcon service to fix permissions.

I don't know why chcon doesn't work in ExecStartPre. My wild guess is that systemd sets as context the context of the ExecStart executable so if it is not right from the beginning, everything fails.

Just for information to those who wonder before policy is officially fixed. Or maybe I should have imported a custom policy..

Comment 2 Lukas Vrabec 2016-06-14 12:13:53 UTC
Hi Aleksandar, 

Could you test your scenario in Permissive SELinux mode? 
(#setenforce 0)
And after tests could you attach all avcs? 
#ausearch -m AVC -ts recent 

Thank you.

Comment 5 Aleksandar Kostadinov 2016-06-14 18:56:32 UTC
Sorry, can't get the idea. Do you have a new policy I can try?

Comment 9 errata-xmlrpc 2016-11-04 02:25:36 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2283.html

Comment 10 Keshav 2018-11-16 06:40:45 UTC
(In reply to errata-xmlrpc from comment #9)
> Since the problem described in this bug report should be
> resolved in a recent advisory, it has been closed with a
> resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated
> files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://rhn.redhat.com/errata/RHBA-2016-2283.html

I've just faced this issue yesterday, is the bug fixed? Can I know the details in which version it was fixed and if not, may I know why it's not fixed, if there's some reason due to which fixing this bug is not recommended/advisable, or know how to get the update if it is fixed. Because I've faced the same issue even in the latest versions.

Comment 11 Keshav 2018-11-16 06:47:18 UTC
(In reply to Aleksandar Kostadinov from comment #1)
> FYI, because the workaround will go away on `restorecon` or RPM upgrade,
> I've created a separate service type=simple, to execute `chcon ...`. I've
> added Requires=chcon.service under [Unit] section of my main service. Now
> upon running main service, systemd will first run my chcon service to fix
> permissions.
> 
> I don't know why chcon doesn't work in ExecStartPre. My wild guess is that
> systemd sets as context the context of the ExecStart executable so if it is
> not right from the beginning, everything fails.
> 
> Just for information to those who wonder before policy is officially fixed.
> Or maybe I should have imported a custom policy..

Hi, thanks for the workaround, it makes things lot easier, just wanted to know if this is the recommended way to do things as of now. Or is there a better/ any other way we can fix this issue, any advice would be invaluable, thanks in advance.

Comment 12 Keshav 2018-11-16 06:50:31 UTC
(In reply to Keshav from comment #10)
> (In reply to errata-xmlrpc from comment #9)
> > Since the problem described in this bug report should be
> > resolved in a recent advisory, it has been closed with a
> > resolution of ERRATA.
> > 
> > For information on the advisory, and where to find the updated
> > files, follow the link below.
> > 
> > If the solution does not work for you, open a new bug report.
> > 
> > https://rhn.redhat.com/errata/RHBA-2016-2283.html
> 
> I've just faced this issue yesterday, is the bug fixed? Can I know the
> details in which version it was fixed and if not, may I know why it's not
> fixed, if there's some reason due to which fixing this bug is not
> recommended/advisable, or know how to get the update if it is fixed. Because
> I've faced the same issue even in the latest versions.

If you know any details, it would be really helpful, thanks.

Comment 13 Red Hat Bugzilla 2023-09-14 03:14:01 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days


Note You need to log in before you can comment on or make changes to this bug.