SELinux-Refpolicy Archive on lore.kernel.org
 help / color / Atom feed
* memlockd
@ 2020-02-12  3:34 Russell Coker
  2020-02-16 15:30 ` memlockd Chris PeBenito
  0 siblings, 1 reply; 2+ messages in thread
From: Russell Coker @ 2020-02-12  3:34 UTC (permalink / raw)
  To: selinux-refpolicy

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

The attach patch adds policy for memlockd, this is a daemon that locks 
important programs and config files into RAM so that if the system is paging 
heavily the sysadmin still has a good chance of being able to login to 
diagnose problems.

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

[-- Attachment #2: memlockd.diff --]
[-- Type: text/x-patch, Size: 3460 bytes --]

Index: refpolicy-2.20200209/policy/modules/services/memlockd.fc
===================================================================
--- /dev/null
+++ refpolicy-2.20200209/policy/modules/services/memlockd.fc
@@ -0,0 +1 @@
+/usr/sbin/memlockd	--	gen_context(system_u:object_r:memlockd_exec_t,s0)
Index: refpolicy-2.20200209/policy/modules/services/memlockd.if
===================================================================
--- /dev/null
+++ refpolicy-2.20200209/policy/modules/services/memlockd.if
@@ -0,0 +1,2 @@
+## <summary>memory lock daemon, keeps important files in RAM.</summary>
+
Index: refpolicy-2.20200209/policy/modules/services/memlockd.te
===================================================================
--- /dev/null
+++ refpolicy-2.20200209/policy/modules/services/memlockd.te
@@ -0,0 +1,42 @@
+policy_module(memlockd, 1.0.0)
+
+########################################
+#
+# Declarations
+#
+
+type memlockd_t;
+type memlockd_exec_t;
+init_daemon_domain(memlockd_t, memlockd_exec_t)
+
+########################################
+#
+# Local policy
+#
+
+allow memlockd_t self:capability { setgid setuid ipc_lock };
+allow memlockd_t self:fifo_file rw_file_perms;
+allow memlockd_t self:unix_dgram_socket { create connect };
+
+# cache /etc/shadow too
+auth_read_shadow(memlockd_t)
+auth_map_shadow(memlockd_t)
+
+sysnet_map_config(memlockd_t)
+files_read_etc_files(memlockd_t)
+
+# for ldd
+corecmd_exec_bin(memlockd_t)
+corecmd_exec_shell(memlockd_t)
+libs_exec_ld_so(memlockd_t)
+
+corecmd_search_bin(memlockd_t)
+files_map_etc_files(memlockd_t)
+# has to exec for ldd
+corecmd_exec_all_executables(memlockd_t)
+corecmd_read_all_executables(memlockd_t)
+
+logging_send_syslog_msg(memlockd_t)
+
+miscfiles_read_localization(memlockd_t)
+
Index: refpolicy-2.20200209/policy/modules/system/sysnetwork.if
===================================================================
--- refpolicy-2.20200209.orig/policy/modules/system/sysnetwork.if
+++ refpolicy-2.20200209/policy/modules/system/sysnetwork.if
@@ -366,6 +366,31 @@ interface(`sysnet_read_config',`
 
 #######################################
 ## <summary>
+##	map network config files.
+## </summary>
+## <desc>
+##	<p>
+##	Allow the specified domain to mmap the
+##	general network configuration files.
+##	</p>
+## </desc>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`sysnet_map_config',`
+	gen_require(`
+		type net_conf_t;
+	')
+
+	files_search_etc($1)
+	allow $1 net_conf_t:file { read_file_perms map };
+')
+
+#######################################
+## <summary>
 ##	Do not audit attempts to read network config files.
 ## </summary>
 ## <param name="domain">
Index: refpolicy-2.20200209/policy/modules/system/authlogin.if
===================================================================
--- refpolicy-2.20200209.orig/policy/modules/system/authlogin.if
+++ refpolicy-2.20200209/policy/modules/system/authlogin.if
@@ -577,6 +577,23 @@ interface(`auth_read_shadow',`
 
 ########################################
 ## <summary>
+##	Map the shadow passwords file (/etc/shadow)
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`auth_map_shadow',`
+	gen_require(`
+		type shadow_t;
+	')
+	allow $1 shadow_t:file map;
+')
+
+########################################
+## <summary>
 ##	Pass shadow assertion for reading.
 ## </summary>
 ## <desc>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: memlockd
  2020-02-12  3:34 memlockd Russell Coker
@ 2020-02-16 15:30 ` Chris PeBenito
  0 siblings, 0 replies; 2+ messages in thread
From: Chris PeBenito @ 2020-02-16 15:30 UTC (permalink / raw)
  To: russell, selinux-refpolicy

On 2/11/20 10:34 PM, Russell Coker wrote:
> The attach patch adds policy for memlockd, this is a daemon that locks
> important programs and config files into RAM so that if the system is paging
> heavily the sysadmin still has a good chance of being able to login to
> diagnose problems.

Please inline patch and add signed-off-by.

> --- /dev/null
> +++ refpolicy-2.20200209/policy/modules/services/memlockd.te
> @@ -0,0 +1,42 @@
> +policy_module(memlockd, 1.0.0)
> +
> +########################################
> +#
> +# Declarations
> +#
> +
> +type memlockd_t;
> +type memlockd_exec_t;
> +init_daemon_domain(memlockd_t, memlockd_exec_t)
> +
> +########################################
> +#
> +# Local policy
> +#
> +
> +allow memlockd_t self:capability { setgid setuid ipc_lock };
> +allow memlockd_t self:fifo_file rw_file_perms;
> +allow memlockd_t self:unix_dgram_socket { create connect };
> +
> +# cache /etc/shadow too
> +auth_read_shadow(memlockd_t)
> +auth_map_shadow(memlockd_t)
> +
> +sysnet_map_config(memlockd_t)
> +files_read_etc_files(memlockd_t)
> +
> +# for ldd
> +corecmd_exec_bin(memlockd_t)
> +corecmd_exec_shell(memlockd_t)
 > +
> +libs_exec_ld_so(memlockd_t)
> +
> +corecmd_search_bin(memlockd_t)
> +files_map_etc_files(memlockd_t)
> +# has to exec for ldd
> +corecmd_exec_all_executables(memlockd_t)

I would guess this is doing mmap_exec but not execute_no_trans.



> +corecmd_read_all_executables(memlockd_t)
> +
> +logging_send_syslog_msg(memlockd_t)
> +
> +miscfiles_read_localization(memlockd_t)
> +
> Index: refpolicy-2.20200209/policy/modules/system/sysnetwork.if
> ===================================================================
> --- refpolicy-2.20200209.orig/policy/modules/system/sysnetwork.if
> +++ refpolicy-2.20200209/policy/modules/system/sysnetwork.if
> @@ -366,6 +366,31 @@ interface(`sysnet_read_config',`
>  
>  #######################################
>  ## <summary>
> +##	map network config files.
> +## </summary>
> +## <desc>
> +##	<p>
> +##	Allow the specified domain to mmap the
> +##	general network configuration files.
> +##	</p>
> +## </desc>
> +## <param name="domain">
> +##	<summary>
> +##	Domain allowed access.
> +##	</summary>
> +## </param>
> +#
> +interface(`sysnet_map_config',`

Please change name to sysnet_mmap_read_config().

> +	gen_require(`
> +		type net_conf_t;
> +	')
> +
> +	files_search_etc($1)
> +	allow $1 net_conf_t:file { read_file_perms map };
> +')
> +

-- 
Chris PeBenito

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12  3:34 memlockd Russell Coker
2020-02-16 15:30 ` memlockd Chris PeBenito

SELinux-Refpolicy Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux-refpolicy/0 selinux-refpolicy/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux-refpolicy selinux-refpolicy/ https://lore.kernel.org/selinux-refpolicy \
		selinux-refpolicy@vger.kernel.org
	public-inbox-index selinux-refpolicy

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux-refpolicy


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git