aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Guy Briggs <rgb@redhat.com>2018-04-09 19:34:22 -0400
committerPaul Moore <paul@paul-moore.com>2018-04-17 17:40:40 -0400
commit4195ed425d3c77f4cf11f3511feeb723a8f48587 (patch)
treeedaae5ca81af1b9936e95059ff80e8fe86aacf39
parentac9a1f6db35521df6da1b81ae70eb665beed35c8 (diff)
audit: normalize MAC_STATUS record
There were two formats of the audit MAC_STATUS record, one of which was more standard than the other. One listed enforcing status changes and the other listed enabled status changes with a non-standard label. In addition, the record was missing information about which LSM was responsible and the operation's completion status. While this record is only issued on success, the parser expects the res= field to be present. old enforcing/permissive: type=MAC_STATUS msg=audit(1523312831.378:24514): enforcing=0 old_enforcing=1 auid=0 ses=1 old enable/disable: type=MAC_STATUS msg=audit(1523312831.378:24514): selinux=0 auid=0 ses=1 List both sets of status and old values and add the lsm= field and the res= field. Here is the new format: type=MAC_STATUS msg=audit(1523293828.657:891): enforcing=0 old_enforcing=1 auid=0 ses=1 enabled=1 old-enabled=1 lsm=selinux res=1 This record already accompanied a SYSCALL record. See: https://github.com/linux-audit/audit-kernel/issues/46 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> [PM: 80-char fixes, merge fuzz, use new SELinux state functions] Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r--security/selinux/selinuxfs.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 6128f5293056..ace893568b98 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -168,10 +168,12 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
168 if (length) 168 if (length)
169 goto out; 169 goto out;
170 audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS, 170 audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
171 "enforcing=%d old_enforcing=%d auid=%u ses=%u", 171 "enforcing=%d old_enforcing=%d auid=%u ses=%u"
172 " enabled=%d old-enabled=%d lsm=selinux res=1",
172 new_value, old_value, 173 new_value, old_value,
173 from_kuid(&init_user_ns, audit_get_loginuid(current)), 174 from_kuid(&init_user_ns, audit_get_loginuid(current)),
174 audit_get_sessionid(current)); 175 audit_get_sessionid(current),
176 selinux_enabled, selinux_enabled);
175 enforcing_set(state, new_value); 177 enforcing_set(state, new_value);
176 if (new_value) 178 if (new_value)
177 avc_ss_reset(state->avc, 0); 179 avc_ss_reset(state->avc, 0);
@@ -279,6 +281,7 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
279 char *page; 281 char *page;
280 ssize_t length; 282 ssize_t length;
281 int new_value; 283 int new_value;
284 int enforcing;
282 285
283 if (count >= PAGE_SIZE) 286 if (count >= PAGE_SIZE)
284 return -ENOMEM; 287 return -ENOMEM;
@@ -296,13 +299,16 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
296 goto out; 299 goto out;
297 300
298 if (new_value) { 301 if (new_value) {
302 enforcing = enforcing_enabled(fsi->state);
299 length = selinux_disable(fsi->state); 303 length = selinux_disable(fsi->state);
300 if (length) 304 if (length)
301 goto out; 305 goto out;
302 audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS, 306 audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
303 "selinux=0 auid=%u ses=%u", 307 "enforcing=%d old_enforcing=%d auid=%u ses=%u"
308 " enabled=%d old-enabled=%d lsm=selinux res=1",
309 enforcing, enforcing,
304 from_kuid(&init_user_ns, audit_get_loginuid(current)), 310 from_kuid(&init_user_ns, audit_get_loginuid(current)),
305 audit_get_sessionid(current)); 311 audit_get_sessionid(current), 0, 1);
306 } 312 }
307 313
308 length = count; 314 length = count;