From bae18addf147f786b24a7d2fabdaf50629bf2565 Mon Sep 17 00:00:00 2001
From: Zdenek Pytela <zpytela@redhat.com>
Date: Mon, 8 Aug 2022 13:13:35 +0200
Subject: [PATCH] Allow openvswitch search tracefs dirs

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

Addresses the following AVC denial:

type=PROCTITLE msg=audit(08/08/2022 05:46:18.724:169) : proctitle=modprobe openvswitch
type=KERN_MODULE msg=audit(08/08/2022 05:46:18.724:169) : name=openvswitch
type=SYSCALL msg=audit(08/08/2022 05:46:18.724:169) : arch=x86_64 syscall=init_module success=yes exit=0 a0=0x5630bbc2d8a0 a1=0xbde36 a2=0x5630b96f9cd2 a3=0x5 items=0 ppid=676 pid=680 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=modprobe exe=/usr/bin/kmod subj=system_u:system_r:openvswitch_t:s0 key=(null)
type=AVC msg=audit(08/08/2022 05:46:18.724:169) : avc:  denied  { search } for  pid=680 comm=modprobe name=events dev="tracefs" ino=69 scontext=system_u:system_r:openvswitch_t:s0 tcontext=system_u:object_r:tracefs_t:s0 tclass=dir permissive=0

The fs_search_tracefs_dirs() interface was added.

Resolves: rhbz#2103487
Signed-off-by: lujie54 <lujie54@huawei.com>
---
 policy/modules/contrib/openvswitch.te |  1 +
 policy/modules/kernel/filesystem.if   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/policy/modules/contrib/openvswitch.te b/policy/modules/contrib/openvswitch.te
index 3092492..9ed1587 100644
--- a/policy/modules/contrib/openvswitch.te
+++ b/policy/modules/contrib/openvswitch.te
@@ -109,6 +109,7 @@ fs_getattr_all_fs(openvswitch_t)
 fs_search_cgroup_dirs(openvswitch_t)
 fs_manage_hugetlbfs_files(openvswitch_t)
 fs_manage_hugetlbfs_dirs(openvswitch_t)
+fs_search_tracefs_dirs(openvswitch_t)
 
 auth_use_nsswitch(openvswitch_t)
 
diff --git a/policy/modules/kernel/filesystem.if b/policy/modules/kernel/filesystem.if
index 90b8393..34de37d 100644
--- a/policy/modules/kernel/filesystem.if
+++ b/policy/modules/kernel/filesystem.if
@@ -6924,6 +6924,24 @@ interface(`fs_rw_onload_sockets',`
 
 ########################################
 ## <summary>
+##	Search tracefs_t directories
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`fs_search_tracefs_dirs',`
+	gen_require(`
+		type tracefs_t;
+	')
+
+	search_dirs_pattern($1, tracefs_t, tracefs_t)
+')
+
+########################################
+## <summary>
 ##	Read and write tracefs_t files
 ## </summary>
 ## <param name="domain">
-- 
1.8.3.1

