Skip to contentSkip to conversation

logging: Various audit tools (auditctl, ausearch, etc) map their config and logs

PATCH Superseded Luis Ressel 2 participants 10 messages Sep 11, 2017 – Sep 12, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 logging: Various audit tools (auditctl, ausearch, etc) map their config and logs

Since there are few reasons to grant read access to audit logs other than for using ausearch, I've added the map permission directly to the relevant read interfaces.

I've checked some parts of the code; most of the mmaps happen inside fdopen(fd, "rm") calls, which can fall back to read(). Hence, we may be able to get away with dontaudits, too.

---
 policy/modules/system/logging.if | 6 ++++++
 policy/modules/system/logging.te | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)
policy/modules/system/logging.if +6 -0
index 8633dfc4..44017b51 100644
@@ -141,6 +141,7 @@ interface(`logging_read_audit_log',`
 
 	files_search_var($1)
 	read_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
 	allow $1 auditd_log_t:dir list_dir_perms;
 ')
 
@@ -338,6 +339,7 @@ interface(`logging_manage_audit_config',`
 
 	files_search_etc($1)
 	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
 ')
 
 ########################################
@@ -359,6 +361,7 @@ interface(`logging_manage_audit_log',`
 	files_search_var($1)
 	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
 	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
 ')
 
 ########################################
@@ -669,6 +672,7 @@ interface(`logging_read_audit_config',`
 
 	files_search_etc($1)
 	read_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
 	allow $1 auditd_etc_t:dir list_dir_perms;
 ')
 
@@ -1196,9 +1200,11 @@ interface(`logging_admin_audit',`
 
 	manage_dirs_pattern($1, auditd_etc_t, auditd_etc_t)
 	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
 
 	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
 	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
 
 	manage_dirs_pattern($1, auditd_var_run_t, auditd_var_run_t)
 	manage_files_pattern($1, auditd_var_run_t, auditd_var_run_t)
policy/modules/system/logging.te +2 -1
index 5eeaece1..47280f44 100644
@@ -104,6 +104,7 @@ allow auditctl_t self:process getcap;
 allow auditctl_t self:netlink_audit_socket nlmsg_readpriv;
 
 read_files_pattern(auditctl_t, auditd_etc_t, auditd_etc_t)
+allow auditctl_t auditd_etc_t:file map;
 allow auditctl_t auditd_etc_t:dir list_dir_perms;
 
 # Needed for adding watches
@@ -151,7 +152,7 @@ allow auditd_t self:fifo_file rw_fifo_file_perms;
 allow auditd_t self:tcp_socket create_stream_socket_perms;
 
 allow auditd_t auditd_etc_t:dir list_dir_perms;
-allow auditd_t auditd_etc_t:file read_file_perms;
+allow auditd_t auditd_etc_t:file { read_file_perms map };
 
 manage_files_pattern(auditd_t, auditd_log_t, auditd_log_t)
 allow auditd_t auditd_log_t:dir setattr;
Signature · 1 line
2.14.1
#1 lore raw

PATCH 2/3 logging: Label /etc/audisp as auditd_etc_t

---
 policy/modules/system/logging.fc | 1 +
 policy/modules/system/logging.te | 1 +
 2 files changed, 2 insertions(+)
policy/modules/system/logging.fc +1 -0
index 0d8a4173..5c166aa9 100644
@@ -3,6 +3,7 @@
 /etc/rsyslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
 /etc/syslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
 /etc/audit(/.*)?		gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh)
+/etc/audisp(/.*)?		gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh)
 /etc/rc\.d/init\.d/auditd --	gen_context(system_u:object_r:auditd_initrc_exec_t,s0)
 /etc/rc\.d/init\.d/rsyslog --	gen_context(system_u:object_r:syslogd_initrc_exec_t,s0)
 
policy/modules/system/logging.te +1 -0
index 47280f44..bbb01137 100644
@@ -261,6 +261,7 @@ files_read_etc_runtime_files(audisp_t)
 
 mls_file_write_all_levels(audisp_t)
 
+logging_read_audit_config(audisp_t)
 logging_send_syslog_msg(audisp_t)
 
 miscfiles_read_localization(audisp_t)
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/3 logging: Label /etc/audisp as auditd_etc_t

Quoted 22 lines · Luis Ressel via refpolicy
---
  policy/modules/system/logging.fc | 1 +
  policy/modules/system/logging.te | 1 +
  2 files changed, 2 insertions(+)
policy/modules/system/logging.fc +1 -0
index 0d8a4173..5c166aa9 100644
@@ -3,6 +3,7 @@
  /etc/rsyslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
  /etc/syslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
  /etc/audit(/.*)?		gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh)
+/etc/audisp(/.*)?		gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh)
  /etc/rc\.d/init\.d/auditd --	gen_context(system_u:object_r:auditd_initrc_exec_t,s0)
  /etc/rc\.d/init\.d/rsyslog --	gen_context(system_u:object_r:syslogd_initrc_exec_t,s0)
 
policy/modules/system/logging.te +0 -0
index 47280f44..bbb01137 100644

policy/modules/system/logging.te files_read_etc_runtime_files(audisp_t) · line 267

Quoted 7 lines
policy/modules/system/logging.te +1 -0
@@ -261,6 +261,7 @@ files_read_etc_runtime_files(audisp_t)
 
  mls_file_write_all_levels(audisp_t)
 
+logging_read_audit_config(audisp_t)
  logging_send_syslog_msg(audisp_t)
 
  miscfiles_read_localization(audisp_t)

I'm not clear why this is needed. I don't think this config should be lumped in with auditd_etc_t, which includes audit rules (hence is system high). The configuration for the dispatcher is not sensitive nor security files like audit rules are.

Signature · 1 line
Chris PeBenito
#3 lore raw

PATCH 2/3 logging: Label /etc/audisp as auditd_etc_t

Quoted 29 lines · On Mon, 11 Sep 2017 20:19:23 -0400 Chris PeBenito via refpolicy…
Quoted 28 lines · Luis Ressel via refpolicy
---
  policy/modules/system/logging.fc | 1 +
  policy/modules/system/logging.te | 1 +
  2 files changed, 2 insertions(+)
(quoted diff) +0 -0

b/policy/modules/system/logging.fc index 0d8a4173..5c166aa9 100644

policy/modules/system/logging.fc +0 -0
@@ -3,6 +3,7 @@
  /etc/rsyslog.conf

gen_context(system_u:object_r:syslog_conf_t,s0) /etc/syslog.conf gen_context(system_u:object_r:syslog_conf_t,s0) /etc/audit(/.*)? gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh) +/etc/audisp(/.*)? gen_context(system_u:object_r:auditd_etc_t,mls_systemhigh) /etc/rc\.d/init\.d/auditd --
gen_context(system_u:object_r:auditd_initrc_exec_t,s0) /etc/rc\.d/init\.d/rsyslog
-- gen_context(system_u:object_r:syslogd_initrc_exec_t,s0)

(quoted diff) +0 -0

b/policy/modules/system/logging.te index 47280f44..bbb01137 100644 --- a/policy/modules/system/logging.te +++ b/policy/modules/system/logging.te @@ -261,6 +261,7 @@ files_read_etc_runtime_files(audisp_t) mls_file_write_all_levels(audisp_t) +logging_read_audit_config(audisp_t)
logging_send_syslog_msg(audisp_t)

Quoted 7 lines
Quoted 1 line

miscfiles_read_localization(audisp_t)

I'm not clear why this is needed. I don't think this config should be lumped in with auditd_etc_t, which includes audit rules (hence is system high). The configuration for the dispatcher is not sensitive nor security files like audit rules are.

Sorry, on further consideration I agree with you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20170912/7ace0651/attachment.bin

#4 lore raw

PATCH 3/3 miscfiles: Allow libfontconfig consumers to map the fonts cache

In reply to Luis Ressel
---
 policy/modules/system/miscfiles.if | 1 +
 1 file changed, 1 insertion(+)
policy/modules/system/miscfiles.if +1 -0
index 0e0ac3bf..e4918b47 100644
@@ -151,6 +151,7 @@ interface(`miscfiles_read_fonts',`
 
 	allow $1 fonts_cache_t:dir list_dir_perms;
 	read_files_pattern($1, fonts_cache_t, fonts_cache_t)
+	allow $1 fonts_cache_t:file map;
 	read_lnk_files_pattern($1, fonts_cache_t, fonts_cache_t)
 ')
 
Signature · 1 line
2.14.1
#5 lore raw

PATCH 3/3 miscfiles: Allow libfontconfig consumers to map the fonts cache

Quoted 9 lines · Luis Ressel via refpolicy
---
  policy/modules/system/miscfiles.if | 1 +
  1 file changed, 1 insertion(+)
policy/modules/system/miscfiles.if +0 -0
index 0e0ac3bf..e4918b47 100644

policy/modules/system/miscfiles.if interface(`miscfiles_read_fonts',` · line 156

Quoted 6 lines
policy/modules/system/miscfiles.if +1 -0
@@ -151,6 +151,7 @@ interface(`miscfiles_read_fonts',`
 
  	allow $1 fonts_cache_t:dir list_dir_perms;
  	read_files_pattern($1, fonts_cache_t, fonts_cache_t)
+	allow $1 fonts_cache_t:file map;
  	read_lnk_files_pattern($1, fonts_cache_t, fonts_cache_t)
  ')

Are you sure that all users of this interface are from libfontconfig? After looking at your other patches, I'm starting to wonder if more abstract interfaces are worthwhile, similar to seutil_libselinux_linked(). Then we could reasonably add the map in a libfontconfig_linked() interface without fear of future users getting unnecessary perms on this generic interface.

Signature · 1 line
Chris PeBenito
#6 lore raw

PATCH 3/3 miscfiles: Allow libfontconfig consumers to map the fonts cache

Quoted 11 lines · On Mon, 11 Sep 2017 20:23:46 -0400 Chris PeBenito <[email protected]> wrote:
Quoted 10 lines · Luis Ressel via refpolicy
---
  policy/modules/system/miscfiles.if | 1 +
  1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/policy/modules/system/miscfiles.if index 0e0ac3bf..e4918b47 100644

policy/modules/system/miscfiles.if +0 -0
@@ -151,6 +151,7 @@ interface(`miscfiles_read_fonts',`
 
Quoted 13 lines

policy/modules/system/miscfiles.if interface(`miscfiles_read_fonts',` · line 156

Quoted 5 lines
policy/modules/system/miscfiles.if +1 -0
  	allow $1 fonts_cache_t:dir list_dir_perms;
  	read_files_pattern($1, fonts_cache_t, fonts_cache_t)
+	allow $1 fonts_cache_t:file map;
  	read_lnk_files_pattern($1, fonts_cache_t, fonts_cache_t)
  ')  

Are you sure that all users of this interface are from libfontconfig? After looking at your other patches, I'm starting to wonder if more abstract interfaces are worthwhile, similar to seutil_libselinux_linked(). Then we could reasonably add the map in a libfontconfig_linked() interface without fear of future users getting unnecessary perms on this generic interface.

Considering that the only path we're labeling fonts_cache_t
is /var/cache/fontconfig: Yes, I am pretty sure that only libfontconfig consumers need acccess permissions for fonts_cache_t. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20170912/5089071b/attachment.bin

#7 lore raw

PATCH 3/3 miscfiles: Allow libfontconfig consumers to map the fonts cache

In reply to Luis Ressel
Quoted 9 lines · Luis Ressel via refpolicy
---
  policy/modules/system/miscfiles.if | 1 +
  1 file changed, 1 insertion(+)
policy/modules/system/miscfiles.if +0 -0
index 0e0ac3bf..e4918b47 100644

policy/modules/system/miscfiles.if interface(`miscfiles_read_fonts',` · line 156

Quoted 6 lines
policy/modules/system/miscfiles.if +1 -0
@@ -151,6 +151,7 @@ interface(`miscfiles_read_fonts',`
 
  	allow $1 fonts_cache_t:dir list_dir_perms;
  	read_files_pattern($1, fonts_cache_t, fonts_cache_t)
+	allow $1 fonts_cache_t:file map;
  	read_lnk_files_pattern($1, fonts_cache_t, fonts_cache_t)
  ')

Merged.

Signature · 1 line
Chris PeBenito
#8 lore raw

PATCH 1/3 logging: Various audit tools (auditctl, ausearch, etc) map their config and logs

In reply to Luis Ressel
Quoted 73 lines · Luis Ressel via refpolicy

Since there are few reasons to grant read access to audit logs other than for using ausearch, I've added the map permission directly to the relevant read interfaces.

I've checked some parts of the code; most of the mmaps happen inside fdopen(fd, "rm") calls, which can fall back to read(). Hence, we may be able to get away with dontaudits, too.

---
  policy/modules/system/logging.if | 6 ++++++
  policy/modules/system/logging.te | 3 ++-
  2 files changed, 8 insertions(+), 1 deletion(-)
policy/modules/system/logging.if +6 -0
index 8633dfc4..44017b51 100644
@@ -141,6 +141,7 @@ interface(`logging_read_audit_log',`
 
  	files_search_var($1)
  	read_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
  	allow $1 auditd_log_t:dir list_dir_perms;
  ')
 
@@ -338,6 +339,7 @@ interface(`logging_manage_audit_config',`
 
  	files_search_etc($1)
  	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
  ')
 
  ########################################
@@ -359,6 +361,7 @@ interface(`logging_manage_audit_log',`
  	files_search_var($1)
  	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
  	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
  ')
 
  ########################################
@@ -669,6 +672,7 @@ interface(`logging_read_audit_config',`
 
  	files_search_etc($1)
  	read_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
  	allow $1 auditd_etc_t:dir list_dir_perms;
  ')
 
@@ -1196,9 +1200,11 @@ interface(`logging_admin_audit',`
 
  	manage_dirs_pattern($1, auditd_etc_t, auditd_etc_t)
  	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
 
  	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
  	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
 
  	manage_dirs_pattern($1, auditd_var_run_t, auditd_var_run_t)
  	manage_files_pattern($1, auditd_var_run_t, auditd_var_run_t)
policy/modules/system/logging.te +1 -0
index 5eeaece1..47280f44 100644
@@ -104,6 +104,7 @@ allow auditctl_t self:process getcap;
  allow auditctl_t self:netlink_audit_socket nlmsg_readpriv;
 
  read_files_pattern(auditctl_t, auditd_etc_t, auditd_etc_t)
+allow auditctl_t auditd_etc_t:file map;
  allow auditctl_t auditd_etc_t:dir list_dir_perms;
 
  # Needed for adding watches

policy/modules/system/logging.te allow auditd_t self:fifo_file rw_fifo_file_perms; · line 158

Quoted 8 lines
policy/modules/system/logging.te +1 -1
@@ -151,7 +152,7 @@ allow auditd_t self:fifo_file rw_fifo_file_perms;
  allow auditd_t self:tcp_socket create_stream_socket_perms;
 
  allow auditd_t auditd_etc_t:dir list_dir_perms;
-allow auditd_t auditd_etc_t:file read_file_perms;
+allow auditd_t auditd_etc_t:file { read_file_perms map };
 
  manage_files_pattern(auditd_t, auditd_log_t, auditd_log_t)
  allow auditd_t auditd_log_t:dir setattr;

I'm waiting on this, pending more testing on dontauditing the map instead.

Signature · 1 line
Chris PeBenito
#9 lore raw

PATCH 1/3 logging: Various audit tools (auditctl, ausearch, etc) map their config and logs

Quoted 80 lines · On Mon, 11 Sep 2017 20:16:12 -0400 Chris PeBenito via refpolicy…
Quoted 79 lines · Luis Ressel via refpolicy

Since there are few reasons to grant read access to audit logs other than for using ausearch, I've added the map permission directly to the relevant read interfaces.

I've checked some parts of the code; most of the mmaps happen inside fdopen(fd, "rm") calls, which can fall back to read(). Hence, we may be able to get away with dontaudits, too.

---
  policy/modules/system/logging.if | 6 ++++++
  policy/modules/system/logging.te | 3 ++-
  2 files changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/policy/modules/system/logging.if index 8633dfc4..44017b51 100644

policy/modules/system/logging.if +6 -0
@@ -141,6 +141,7 @@ interface(`logging_read_audit_log',`
 
  	files_search_var($1)
  	read_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
  	allow $1 auditd_log_t:dir list_dir_perms;
  ')
 
@@ -338,6 +339,7 @@ interface(`logging_manage_audit_config',`
 
  	files_search_etc($1)
  	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
  ')
 
  ########################################
@@ -359,6 +361,7 @@ interface(`logging_manage_audit_log',`
  	files_search_var($1)
  	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
  	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
  ')
 
  ########################################
@@ -669,6 +672,7 @@ interface(`logging_read_audit_config',`
 
  	files_search_etc($1)
  	read_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
  	allow $1 auditd_etc_t:dir list_dir_perms;
  ')
 
@@ -1196,9 +1200,11 @@ interface(`logging_admin_audit',`
 
  	manage_dirs_pattern($1, auditd_etc_t, auditd_etc_t)
  	manage_files_pattern($1, auditd_etc_t, auditd_etc_t)
+	allow $1 auditd_etc_t:file map;
 
  	manage_dirs_pattern($1, auditd_log_t, auditd_log_t)
  	manage_files_pattern($1, auditd_log_t, auditd_log_t)
+	allow $1 auditd_log_t:file map;
 
  	manage_dirs_pattern($1, auditd_var_run_t,
 auditd_var_run_t) manage_files_pattern($1, auditd_var_run_t,

auditd_var_run_t) diff --git a/policy/modules/system/logging.te b/policy/modules/system/logging.te index 5eeaece1..47280f44 100644

policy/modules/system/logging.te +1 -0
@@ -104,6 +104,7 @@ allow auditctl_t self:process getcap;
  allow auditctl_t self:netlink_audit_socket nlmsg_readpriv;
 
  read_files_pattern(auditctl_t, auditd_etc_t, auditd_etc_t)
+allow auditctl_t auditd_etc_t:file map;
  allow auditctl_t auditd_etc_t:dir list_dir_perms;
 
  # Needed for adding watches
@@ -151,7 +152,7 @@ allow auditd_t self:fifo_file

rw_fifo_file_perms; allow auditd_t self:tcp_socket create_stream_socket_perms;
allow auditd_t auditd_etc_t:dir list_dir_perms;

policy/modules/system/logging.te +1 -1
-allow auditd_t auditd_etc_t:file read_file_perms;
+allow auditd_t auditd_etc_t:file { read_file_perms map };
Quoted 6 lines
Quoted 2 lines

manage_files_pattern(auditd_t, auditd_log_t, auditd_log_t) allow auditd_t auditd_log_t:dir setattr;

I'm waiting on this, pending more testing on dontauditing the map instead.

I've dug through the code a bit longer, and haven't found anything
other than fdopen() calls. I'll submit a patch with dontaudits. -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20170912/da1ec117/attachment.bin