2019-12-06 19:25:49

by Lawrence, Stephen

[permalink] [raw]
Subject: [PATCH 0/2] Fixes to enable slapd to run

slapd requires the map permission on some files, including certs, files
in /usr, and the slapd database. Also uses symlink in /tmp and crypto
sysctls. These two patches add the needed permissions.

Steve Lawrence (2):
ldap: various permissions required by slapd
miscfiles: reading certs allows map permission also

policy/modules/services/ldap.te | 6 +++++-
policy/modules/system/miscfiles.if | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)

--
2.21.0


2019-12-06 19:25:49

by Lawrence, Stephen

[permalink] [raw]
Subject: [PATCH 1/2] ldap: various permissions required by slapd

- requires the map permission when reading /usr and LDAP database files
- creates symlinks in /tmp in addition to files and directory
- needs to read crypto sysctls
---
policy/modules/services/ldap.te | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/policy/modules/services/ldap.te b/policy/modules/services/ldap.te
index 83478fa0..47d40770 100644
--- a/policy/modules/services/ldap.te
+++ b/policy/modules/services/ldap.te
@@ -63,6 +63,7 @@ read_lnk_files_pattern(slapd_t, slapd_cert_t, slapd_cert_t)
manage_dirs_pattern(slapd_t, slapd_db_t, slapd_db_t)
manage_files_pattern(slapd_t, slapd_db_t, slapd_db_t)
manage_lnk_files_pattern(slapd_t, slapd_db_t, slapd_db_t)
+mmap_read_files_pattern(slapd_t, slapd_db_t, slapd_db_t)

allow slapd_t slapd_etc_t:file read_file_perms;

@@ -83,7 +84,8 @@ manage_lnk_files_pattern(slapd_t, slapd_replog_t, slapd_replog_t)

manage_dirs_pattern(slapd_t, slapd_tmp_t, slapd_tmp_t)
manage_files_pattern(slapd_t, slapd_tmp_t, slapd_tmp_t)
-files_tmp_filetrans(slapd_t, slapd_tmp_t, { file dir })
+manage_lnk_files_pattern(slapd_t, slapd_tmp_t, slapd_tmp_t)
+files_tmp_filetrans(slapd_t, slapd_tmp_t, { file dir lnk_file })

manage_files_pattern(slapd_t, slapd_tmpfs_t, slapd_tmpfs_t)
fs_tmpfs_filetrans(slapd_t, slapd_tmpfs_t, file)
@@ -94,6 +96,7 @@ manage_sock_files_pattern(slapd_t, slapd_runtime_t, slapd_runtime_t)
files_pid_filetrans(slapd_t, slapd_runtime_t, { dir file sock_file })

kernel_read_system_state(slapd_t)
+kernel_read_crypto_sysctls(slapd_t)
kernel_read_kernel_sysctls(slapd_t)

corenet_all_recvfrom_unlabeled(slapd_t)
@@ -118,6 +121,7 @@ fs_getattr_all_fs(slapd_t)
fs_search_auto_mountpoints(slapd_t)

files_read_etc_runtime_files(slapd_t)
+files_map_usr_files(slapd_t)
files_read_usr_files(slapd_t)
files_list_var_lib(slapd_t)

--
2.21.0

2019-12-06 19:25:53

by Lawrence, Stephen

[permalink] [raw]
Subject: [PATCH 2/2] miscfiles: reading certs allows map permission also

---
policy/modules/system/miscfiles.if | 2 ++
1 file changed, 2 insertions(+)

diff --git a/policy/modules/system/miscfiles.if b/policy/modules/system/miscfiles.if
index df11794a..4ff82afb 100644
--- a/policy/modules/system/miscfiles.if
+++ b/policy/modules/system/miscfiles.if
@@ -107,6 +107,7 @@ interface(`miscfiles_read_all_certs',`

allow $1 cert_type:dir list_dir_perms;
read_files_pattern($1, cert_type, cert_type)
+ allow $1 cert_type:file map;
read_lnk_files_pattern($1, cert_type, cert_type)
')

@@ -128,6 +129,7 @@ interface(`miscfiles_read_generic_certs',`

allow $1 cert_t:dir list_dir_perms;
read_files_pattern($1, cert_t, cert_t)
+ allow $1 cert_t:file map;
read_lnk_files_pattern($1, cert_t, cert_t)
')

--
2.21.0

2019-12-26 16:58:53

by Chris PeBenito

[permalink] [raw]
Subject: Re: [PATCH 2/2] miscfiles: reading certs allows map permission also

On 12/6/19 2:25 PM, Lawrence, Stephen wrote:
> ---
> policy/modules/system/miscfiles.if | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/policy/modules/system/miscfiles.if b/policy/modules/system/miscfiles.if
> index df11794a..4ff82afb 100644
> --- a/policy/modules/system/miscfiles.if
> +++ b/policy/modules/system/miscfiles.if
> @@ -107,6 +107,7 @@ interface(`miscfiles_read_all_certs',`
>
> allow $1 cert_type:dir list_dir_perms;
> read_files_pattern($1, cert_type, cert_type)
> + allow $1 cert_type:file map;
> read_lnk_files_pattern($1, cert_type, cert_type)
> ')
>
> @@ -128,6 +129,7 @@ interface(`miscfiles_read_generic_certs',`
>
> allow $1 cert_t:dir list_dir_perms;
> read_files_pattern($1, cert_t, cert_t)
> + allow $1 cert_t:file map;
> read_lnk_files_pattern($1, cert_t, cert_t)
> ')

Needs a separate map or mmap_read interface. I'm not aware of all cert
reading requiring mmap.

--
Chris PeBenito