Skip to contentSkip to conversation

selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy()

PATCH In review lily 2 participants 2 messages Aug 20, 2022 SELinux security module

lore
Share & tools
lore

lily

author
#0 lore raw

PATCH 1/1 selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy()

The function audit_log_start() can fail, so its return value should be checked against NULL.

---
 security/selinux/ss/services.c | 3 +++
 1 file changed, 3 insertions(+)
security/selinux/ss/services.c +3 -0
index fe5fcf571c56..41d4c4ed93b7 100644
@@ -3271,6 +3271,9 @@ int security_sid_mls_copy(struct selinux_state *state,
 				ab = audit_log_start(audit_context(),
 						     GFP_ATOMIC,
 						     AUDIT_SELINUX_ERR);
+				if (!ab)
+					goto out_unlock;
+
 				audit_log_format(ab,
 						 "op=security_sid_mls_copy invalid_context=");
 				/* don't record NUL with untrusted strings */
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · lily

The function audit_log_start() can fail, so its return value should be checked against NULL.

---
 security/selinux/ss/services.c | 3 +++
 1 file changed, 3 insertions(+)

audit_log_start() can safely return NULL as the audit_log_*() functions are designed to handle a NULL audit_buffer. This is an expected behavior and not a bug.

Signature · 1 line
paul-moore.com