mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy()
@ 2022-08-20  8:26 lily
  2022-08-20 14:19 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: lily @ 2022-08-20  8:26 UTC (permalink / raw)
  To: selinux, linux-kernel
  Cc: paul, stephen.smalley.work, eparis, cgzones, michalorzel.eng,
	xiujianfeng, omosnace, lily

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

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 security/selinux/ss/services.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index fe5fcf571c56..41d4c4ed93b7 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -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 */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy()
  2022-08-20  8:26 [PATCH v1] selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy() lily
@ 2022-08-20 14:19 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2022-08-20 14:19 UTC (permalink / raw)
  To: lily
  Cc: selinux, linux-kernel, stephen.smalley.work, eparis, cgzones,
	michalorzel.eng, xiujianfeng, omosnace

On Sat, Aug 20, 2022 at 4:26 AM lily <floridsleeves@gmail.com> wrote:
>
> The function audit_log_start() can fail, so its return value should be
> checked against NULL.
>
> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  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.

-- 
paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-20 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20  8:26 [PATCH v1] selinux/ss/services.c: check the return value of audit_log_start() in security_sid_mls_copy() lily
2022-08-20 14:19 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®