Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2129438

Summary: Cannot use systemd to start up wireguard
Product: Red Hat Enterprise Linux 9 Reporter: Brigham Keys <bkeys>
Component: selinux-policyAssignee: Nikola Knazekova <nknazeko>
Status: CLOSED DUPLICATE QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: high    
Version: CentOS StreamCC: bstinson, davide.principi, haliu, jianliu, jwboyer, lvrabec, mmalik, network-qe, ssekidde, zpytela
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-12 14:42:00 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:

Description Brigham Keys 2022-09-23 18:48:27 UTC
Description of problem:
I have been unable to run my wireguard VPN on CentOS Stream (ppc64le) using systemd, I have to run wg-quick up wg0 manually for it to work, for some reason it will work properly for about 2 days and then I have to restart the vpn (without systemd).

Version-Release number of selected component (if applicable):
wireguard-tools v1.0.20210914 - https://git.zx2c4.com/wireguard-tools/


How reproducible:
Install CentOS Stream on a ppc64le machine, make sure that the wg0.conf file is relabled with SELinux

Steps to Reproduce:
1.systemctl start wg-quick

Actual results:
× wg-quick - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Fri 2022-09-23 14:42:45 EDT; 5min ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 1531376 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=36)
   Main PID: 1531376 (code=exited, status=36)
        CPU: 208ms

Sep 23 14:42:44 pserver wg-quick[1531376]: [#] ip -4 route add 10.0.6.1/32 dev wg0
Sep 23 14:42:44 pserver wg-quick[1531376]: [#] ip -4 route add 10.0.5.1/32 dev wg0
Sep 23 14:42:44 pserver wg-quick[1531376]: [#] ip -4 route add 10.0.4.1/32 dev wg0
Sep 23 14:42:44 pserver wg-quick[1531376]: [#] ip -4 route add 10.0.3.0/24 dev wg0
Sep 23 14:42:44 pserver wg-quick[1531376]: [#] firewall-cmd --zone=public --add-port 51820/udp && firewall-cmd --zone=public --add-masquerade
Sep 23 14:42:44 pserver wg-quick[1531418]: Error: DBUS_ERROR: Failed to connect to socket /run/dbus/system_bus_socket: Permission denied
Sep 23 14:42:44 pserver wg-quick[1531376]: [#] ip link delete dev wg0
Sep 23 14:42:45 pserver systemd[1]: wg-quick: Main process exited, code=exited, status=36/n/a
Sep 23 14:42:45 pserver systemd[1]: wg-quick: Failed with result 'exit-code'.
Sep 23 14:42:45 pserver systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.

Expected results:
The VPN starting up successfully the way it does if I run an additional command

Comment 1 Hangbin Liu 2022-09-26 08:53:12 UTC
(In reply to Brigham Keys from comment #0)
> Sep 23 14:42:44 pserver wg-quick[1531376]: [#] firewall-cmd --zone=public --add-port 51820/udp && firewall-cmd --zone=public --add-masquerade
> Sep 23 14:42:44 pserver wg-quick[1531418]: Error: DBUS_ERROR: Failed to connect to socket /run/dbus/system_bus_socket: Permission denied

This looks like the wg-quick was stop by selinux due to run firewall-cmd.

Hi Brigham, would you like to share your wg-quick file?

Thanks
Hangbin

Comment 2 Brigham Keys 2022-09-26 13:03:59 UTC
[Interface]
Address    = <REDACTED>
PrivateKey = <REDACTED>
PostUp     = firewall-cmd --zone=public --add-port 51820/udp && firewall-cmd --zone=public --add-masquerade
PostDown   = firewall-cmd --zone=public --remove-port 51820/udp && firewall-cmd --zone=public --remove-masquerade
ListenPort = 51820

[Peer]
PublicKey    = <REDACTED>
AllowedIPs   = <REDACTED>

Comment 3 Hangbin Liu 2022-09-27 07:04:51 UTC
(In reply to Brigham Keys from comment #2)
> [Interface]

Thanks Brigham, I can reproduce this issue with your config file.
This looks like a SELinux policy issue. I will ask the SELinux team first.

Comment 5 Zdenek Pytela 2022-09-27 11:46:44 UTC
Are there any AVC denials audited?

It would also be good to see if the script snippets work out of the box or also need to be backed by SELinux rules.

Comment 6 Hangbin Liu 2022-09-28 04:11:25 UTC
(In reply to Zdenek Pytela from comment #5)
> Are there any AVC denials audited?
> 
> It would also be good to see if the script snippets work out of the box or
> also need to be backed by SELinux rules.

Here is the report

# aureport -a

AVC Report
===============================================================
# date time comm subj syscall class permission obj result event
===============================================================
1. 09/28/2022 00:06:14 wg system_u:system_r:wireguard_t:s0 41 udp_socket create system_u:system_r:wireguard_t:s0 denied 81
2. 09/28/2022 00:06:14 wg system_u:system_r:wireguard_t:s0 41 udp_socket create system_u:system_r:wireguard_t:s0 denied 82
3. 09/28/2022 00:06:14 firewall-cmd system_u:system_r:wireguard_t:s0 257 dir search system_u:object_r:cert_t:s0 denied 84
4. 09/28/2022 00:06:14 firewall-cmd system_u:system_r:wireguard_t:s0 42 dir search system_u:object_r:system_dbusd_var_run_t:s0 denied 85

Comment 7 Hangbin Liu 2023-01-06 08:33:55 UTC
*** Bug 2155773 has been marked as a duplicate of this bug. ***

Comment 10 Nikola Knazekova 2023-01-12 14:42:00 UTC

*** This bug has been marked as a duplicate of bug 2149452 ***