Bug 2023456

Summary: SELinux does not allow nftables to forward packets
Product: Red Hat Enterprise Linux 9 Reporter: Bohdan Milar <bmilar>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.0CC: lvrabec, mmalik, ssekidde, vmojzis, zpytela
Target Milestone: rcKeywords: Regression, Triaged
Target Release: 9.0Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-34.1.19-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 15:49:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Deadline: 2022-01-11   

Description Bohdan Milar 2021-11-15 18:38:51 UTC
Description of problem:
I created a local shared sub-network to allow secondary computer to share connections of the main computer. Connection seemed to work, but I was only able to ping the main computer from the secondary one. Pings to other system (neither local nor internet ones) did not work.

Connections from the main computer to local network and internet were functional (from the main computer). SELinux was set to enforcing mode.


Version-Release number of selected component (if applicable):
selinux-policy-34.1.18-1.el9.noarch
NetworkManager-1.34.0-0.1.el9.x86_64
nftables-0.9.8-9.el9.x86_64


How reproducible:
Always


Steps to Reproduce:
1. Have a computer (nb1) with 2 network ports (I use built-in ethernet + USB-to-ethernet adapter) and RHEL 9 installed.
2. Have nb1 connected to local network (and internet) via one of the ports. (Try "ping www.redhat.com")
3. Create a shared sub-net connection (on nb1):
nmcli connection add type ethernet con-name USB-eth-shared ipv4.method shared ipv4.addresses 192.168.81.1/24
4. Activate the shared sub-net connection on the other network port (list available ports with "ip a"):
nmcli connection up USB-eth-shared ifname <your_if_name>
5. Connect the second computer (nb2) to the second network port on nb1.
6. nb2 should get network auto-configured (DHCP) having nb1 as default gateway and you should be able to ping nb1.
7. Try "ping www.redhat.com" on nb2.


Actual results:
- New SELinux security alert appears (step 4).
- ping from nb2 to internet does not work (100 % packet loss).


Expected results:
- No SELinux alert should appear.
- ping from nb2 to internet should work.


Additional info:

Works with SELinux in permisive mode - workaround (on nb1):
1. nmcli connection down USB-eth-shared
2. sudo setenforce 0
3. nmcli connection up USB-eth-shared ifname <your_if_name>



SELinux is preventing /usr/sbin/nft from open access on the fifo_file fifo_file.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that nft should be allowed open access on the fifo_file fifo_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'nft' --raw | audit2allow -M my-nft
# semodule -X 300 -i my-nft.pp

Additional Information:
Source Context                system_u:system_r:iptables_t:s0
Target Context                system_u:system_r:NetworkManager_t:s0
Target Objects                fifo_file [ fifo_file ]
Source                        nft
Source Path                   /usr/sbin/nft
Port                          <Unknown>
Host                          p3551
Source RPM Packages           nftables-0.9.8-9.el9.x86_64
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-34.1.18-1.el9.noarch
Local Policy RPM              selinux-policy-targeted-34.1.18-1.el9.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     p3551
Platform                      Linux p3551 5.14.0-8.el9.x86_64 #1 SMP Tue Oct 19
                              03:58:57 EDT 2021 x86_64 x86_64
Alert Count                   5
First Seen                    2021-11-12 17:26:08 CET
Last Seen                     2021-11-15 11:51:19 CET
Local ID                      39dfc045-862c-45e6-a90c-166958fa29b3

Raw Audit Messages
type=AVC msg=audit(1636973479.219:4177): avc:  denied  { open } for  pid=174956 comm="nft" path="pipe:[2186495]" dev="pipefs" ino=2186495 scontext=system_u:system_r:iptables_t:s0 tcontext=system_u:system_r:NetworkManager_t:s0 tclass=fifo_file permissive=0


type=SYSCALL msg=audit(1636973479.219:4177): arch=x86_64 syscall=openat success=no exit=EACCES a0=ffffff9c a1=7f42c61643a1 a2=0 a3=0 items=0 ppid=1750 pid=174956 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=nft exe=/usr/sbin/nft subj=system_u:system_r:iptables_t:s0 key=(null)

Hash: nft,iptables_t,NetworkManager_t,fifo_file,open

Comment 14 Bohdan Milar 2022-01-13 16:53:48 UTC
I can confirm.

selinux-policy-34.1.20-1.el9 works fine for me.

Even with enforcing SELinux, the connection is established and nb2 (connected to the created subnet) has access to internet.

Than you for the fix.

Comment 16 errata-xmlrpc 2022-05-17 15:49:53 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 (new packages: selinux-policy), 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-2022:3918