Skip to contentSkip to conversation

libselinux: Add new log callback levels for enforcing and policy load notices.

PATCH Applied Chris PeBenito 2 participants 3 messages Aug 27, 2020 – Aug 31, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: Add new log callback levels for enforcing and policy load notices.

This will enable userspace object managers to send proper audits for policy loads and setenforce messages generated by the userspace AVC code.

---
 libselinux/include/selinux/selinux.h       | 2 ++
 libselinux/man/man3/selinux_set_callback.3 | 5 +++++
 libselinux/src/avc_internal.c              | 4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)
libselinux/include/selinux/selinux.h +2 -0
index c22834e5..ae98a92e 100644
@@ -182,6 +182,8 @@ extern void selinux_set_callback(int type, union selinux_callback cb);
 #define SELINUX_WARNING		1
 #define SELINUX_INFO		2
 #define SELINUX_AVC		3
+#define SELINUX_POLICYLOAD	4
+#define SELINUX_SETENFORCE	5
 #define SELINUX_TRANS_DIR	"/var/run/setrans"
 
 /* Compute an access decision. */
libselinux/man/man3/selinux_set_callback.3 +5 -0
index a4c613ad..6dfe5ff6 100644
@@ -46,6 +46,11 @@ argument indicates the type of message and will be set to one of the following:
 .B SELINUX_INFO
 
 .B SELINUX_AVC
+
+.B SELINUX_POLICYLOAD
+
+.B SELINUX_SETENFORCE
+
 .
 .TP
 .B SELINUX_CB_AUDIT
libselinux/src/avc_internal.c +2 -2
index 4ef92452..572b2159 100644
@@ -58,7 +58,7 @@ int avc_process_setenforce(int enforcing)
 {
 	int rc = 0;
 
-	avc_log(SELINUX_INFO,
+	avc_log(SELINUX_SETENFORCE,
 		"%s:  received setenforce notice (enforcing=%d)\n",
 		avc_prefix, enforcing);
 	if (avc_setenforce)
@@ -80,7 +80,7 @@ int avc_process_policyload(uint32_t seqno)
 {
 	int rc = 0;
 
-	avc_log(SELINUX_INFO,
+	avc_log(SELINUX_POLICYLOAD,
 		"%s:  received policyload notice (seqno=%u)\n",
 		avc_prefix, seqno);
 	rc = avc_ss_reset(seqno);
Signature · 1 line
2.26.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Chris PeBenito

This will enable userspace object managers to send proper audits for policy loads and setenforce messages generated by the userspace AVC code.

libselinux/include/selinux/selinux.h extern void selinux_set_callback(int type, union selinux_callback cb); · line 187

Quoted 12 lines

---

libselinux/include/selinux/selinux.h +2 -0
index c22834e5..ae98a92e 100644
@@ -182,6 +182,8 @@ extern void selinux_set_callback(int type, union selinux_callback cb);
 #define SELINUX_WARNING                1
 #define SELINUX_INFO           2
 #define SELINUX_AVC            3
+#define SELINUX_POLICYLOAD     4
+#define SELINUX_SETENFORCE     5
 #define SELINUX_TRANS_DIR      "/var/run/setrans"

Not changed by your patch but that SELINUX_TRANS_DIR definition is very odd, certainly shouldn't be next to these other definitions. Will have to look into what uses that outside of libselinux. At some point we should likely also fix up the indentation/alignment of the values above but that can be separate.