From 355731c1c456907fc7097257e50e4c0377f17953 Mon Sep 17 00:00:00 2001
From: Zdenek Pytela <zpytela@redhat.com>
Date: Wed, 7 Sep 2022 09:41:19 +0200
Subject: [PATCH] Allow init remount all file_type filesystems

Addresses the following AVC denial:

type=PROCTITLE msg=audit(1650874039.465:8427): proctitle="(coredump)"
type=PATH msg=audit(1650874039.465:8427): item=0 name="/proc/self/fd/4" inode=256 dev=00:32 mode=040755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:swapfile_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=SYSCALL msg=audit(1650874039.465:8427): arch=c000003e syscall=165 success=yes exit=0 a0=0 a1=7ffeea790a00 a2=0 a3=1021 items=1 ppid=1 pid=208737 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="(coredump)" exe="/usr/lib/systemd/systemd" subj=system_u:system_r:init_t:s0 key=(null)
type=AVC msg=audit(1650874039.465:8427): avc:  denied  { remount } for  pid=208737 comm="(coredump)" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:swapfile_t:s0 tclass=filesystem permissive=1

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

diff --git a/policy/modules/kernel/files.if b/policy/modules/kernel/files.if
index 2bb2908df..165eb4a12 100644
--- a/policy/modules/kernel/files.if
+++ b/policy/modules/kernel/files.if
@@ -1947,6 +1947,24 @@ interface(`files_unmount_all_file_type_fs',`
 	allow $1 file_type:filesystem unmount;
 ')
 
+########################################
+## <summary>
+##	Remount all filesystems with the type of a file.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`files_remount_all_file_type_fs',`
+	gen_require(`
+		attribute file_type;
+	')
+
+	allow $1 file_type:filesystem remount;
+')
+
 ########################################
 ## <summary>
 ##	Read all non-authentication related
diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te
index f369aa50e..c81f0d0be 100644
--- a/policy/modules/system/init.te
+++ b/policy/modules/system/init.te
@@ -627,6 +627,7 @@ dev_rw_wireless(init_t)
 files_search_all(init_t)
 files_mounton_all_mountpoints(init_t)
 files_unmount_all_file_type_fs(init_t)
+files_remount_all_file_type_fs(init_t)
 files_mounton_kernel_symbol_table(init_t)
 files_manage_all_pid_dirs(init_t)
 files_write_all_pid_sockets(init_t)
-- 
2.27.0

