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 1780023 - VRF is not usable in systemd services context with SELinux enabled
Summary: VRF is not usable in systemd services context with SELinux enabled
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: iproute
Version: 8.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.5
Assignee: Andrea Claudi
QA Contact: Mingyu Shi
Marc Muehlfeld
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-12-05 09:23 UTC by Renaud Métrich
Modified: 2023-12-25 14:13 UTC (History)
16 users (show)

Fixed In Version: iproute-6.2.0-5.el8_9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-14 15:48:50 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)
ausearch -m avc -ts recent (27.46 KB, text/plain)
2021-05-31 06:28 UTC, Gris Ge
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-168359 0 None None None 2023-11-14 00:17:37 UTC
Red Hat Product Errata RHBA-2023:7103 0 None None None 2023-11-14 15:49:09 UTC

Description Renaud Métrich 2019-12-05 09:23:55 UTC
Description of problem:

The VRF feature seems not usable at all in RHEL8.1 for 2 reasons:

1. It requires cgroupv2 which is Technology Preview

more important (assuming a customer can deal with this from support perspective)

2. VRF code is not SELinux aware, which is probably should, when used with "ip vrf exec <vrf> ..." command, this is what is described below.

---

In order to execute a service with VRF, the customer has to encapsulate the ExecStart command into "ip vrf exec" command, as shown in the example unit below (with httpd):

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
ExecStart=/usr/sbin/ip vrf exec vrf1 /usr/sbin/httpd $OPTIONS -DFOREGROUND
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Additionally, the unit file must have capabilities set:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# setcap 'cap_sys_admin=+epi' /path/to/service/unit.service
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Assuming SELinux is in permissive mode, we can then see that the executed process (here "httpd") will run as "ifconfig_t" context (the context of "ip" command).
This is incorrect. Instead "httpd" should run in "httpd_t" context.

This is due to missing Allow and Transitions rules, e.g.

1. We would need a "allow ifconfig_t httpd_exec_t:file { execute execute_no_trans open read }" rule to execute the binary, for now, only the following rules exist:
2. We would all need a rule to transition from "ifconfig_t" to "httpd_t", but it doesn't exist for now: only the following transitions exist:

Since any application requiring the network would potentially need this (not only httpd, almost everything in fact), we would basically want to let "ifconfig_t" domain be able to execute and transition to everything else, almost.

It hence looks like to me the "ip vrf exec" command was not designed with SELinux in mind, probably something smarter needs to be done, for example have "ip vrf exec" command switch to some special context similar to "init_t" so that it can then execute binaries safely. Not doing so would result in any "ip" or "ifconfig "command (running as "ifconfig_t") to be able to execute everything, which raises probably security concerns.


Version-Release number of selected component (if applicable):

iproute-4.18.0-15.el8


How reproducible:

Always


Steps to Reproduce (with "httpd" as an example):
1. Install "httpd" package

  # yum -y install httpd

2. Customize "httpd" service to run in a VRF

  # systemctl edit httpd --full

  Edit ExecStart and add ExecStartPre and ExecStopPost (for convenience) as shown below:

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  ExecStartPre=/usr/sbin/ip link add dev vrf1 type vrf table 256
  ExecStopPost=/usr/sbin/ip link delete dev vrf1
  ExecStart=/usr/sbin/ip vrf exec vrf1 /usr/sbin/httpd $OPTIONS -DFOREGROUND
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

3. Enable capabilities

  # setcap 'cap_sys_admin=+epi' /etc/systemd/system/httpd.service

4. Move the system to Permissive and execute the service

  # setenforce permissive
  # systemctl start httpd

5. Check for httpd context and look at AVCs

  # ps -eafZ | grep httpd
  # ausearch -m avc -ts recent


Actual results:

We can see the wrong context:

system_u:system_r:ifconfig_t:s0 root      2556     1  0 10:20 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:ifconfig_t:s0 apache    2559  2556  0 10:20 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
...

and AVCs, due to httpd running as "ifconfig_t".

Expected results:

No AVCs and expected "httpd_t" context for "httpd"

Comment 8 Gris Ge 2021-05-31 06:27:49 UTC
Hi Tomas Jaros,

This sounds like a SELinux issue to me. Can you take a look?

Comment 9 Gris Ge 2021-05-31 06:28:15 UTC
Created attachment 1788148 [details]
ausearch -m avc -ts recent

Comment 58 Andrea Claudi 2023-08-23 17:35:11 UTC
Patch series posted upstream, waiting for feedback: https://patchwork.kernel.org/project/netdevbpf/list/?series=778694

Comment 80 errata-xmlrpc 2023-11-14 15:48:50 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 (iproute bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2023:7103


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