From f0cb46186be7437cd78c96271938b3902cec10b7 Mon Sep 17 00:00:00 2001
From: Zdenek Pytela <zpytela@redhat.com>
Date: Wed, 26 Jan 2022 10:54:36 +0100
Subject: [PATCH] Allow NetworkManager talk with unconfined user over unix
 domain dgram socket

Reference: https://gitbub.com/fedora-selinux/selinux-policy/commit/f0cb46186be7437cd78c96271938b3902cec10b7
Conflict: NA

This permission is required for wpa_cli be able to communicate with the
wpa_supplicant service in CLI. The wpa control interface socket file is
open in /run/wpa_supplicant, the client socket in /tmp.

This issue possibly started to appear after unconfined_t was removed from the
unpriv_user_domain attribute with the 4b4eec49a55 ("Removed adding to
attribute unpriv_userdomain from userdom_unpriv_type template") commit.

Addresses the following AVC denial:

type=PROCTITLE msg=audit(01/24/2022 02:56:04.040:501) : proctitle=/usr/sbin/wpa_supplicant -g /run/wpa_supplicant/global -c /etc/wpa_supplicant/wpa_supplicant.conf -u -s
type=PATH msg=audit(01/24/2022 02:56:04.040:501) : item=0 name=/tmp/wpa_ctrl_26793-1 inode=730142 dev=fd:01 mode=socket,755 ouid=root ogid=root rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(01/24/2022 02:56:04.040:501) : cwd=/
type=SOCKADDR msg=audit(01/24/2022 02:56:04.040:501) : saddr={ saddr_fam=local path=/tmp/wpa_ctrl_26793-1 }
type=SYSCALL msg=audit(01/24/2022 02:56:04.040:501) : arch=x86_64 syscall=sendto success=yes exit=5 a0=0x5 a1=0x5556370a4860 a2=0x5 a3=0x0 items=1 ppid=1 pid=26219 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=wpa_supplicant exe=/usr/sbin/wpa_supplicant subj=system_u:system_r:NetworkManager_t:s0 key=(null)
type=AVC msg=audit(01/24/2022 02:56:04.040:501) : avc:  denied  { sendto } for  pid=26219 comm=wpa_supplicant path=/tmp/wpa_ctrl_26793-1 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=unix_dgram_socket permissive=1

Resolves: rhbz#2044048
Signed-off-by: lujie54 <lujie54@huawei.com>
---
 policy/modules/contrib/networkmanager.te | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/policy/modules/contrib/networkmanager.te b/policy/modules/contrib/networkmanager.te
index 8230910..1a53f51 100644
--- a/policy/modules/contrib/networkmanager.te
+++ b/policy/modules/contrib/networkmanager.te
@@ -498,6 +498,11 @@ optional_policy(`
 	openvswitch_stream_connect(NetworkManager_t)
 ')
 
+optional_policy(`
+	unconfined_dgram_send(NetworkManager_t)
+')
+
+
 tunable_policy(`use_ecryptfs_home_dirs',`
 	fs_manage_ecryptfs_files(NetworkManager_t)
 ')
-- 
1.8.3.1

