All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] integrity: return early if audit_log_start return NULL
@ 2021-10-09  6:30 Gaosheng Cui
  2021-10-12 14:15 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Gaosheng Cui @ 2021-10-09  6:30 UTC (permalink / raw)
  To: jmorris, serge
  Cc: linux-security-module, linux-kernel, xiujianfeng, wangweiyang2

audit_log_start() may return NULL in below cases:
  - when audit is not initialized.
  - when audit backlog limit exceeds.

After the call to audit_log_start() is made and then possible NULL audit
buffer argument is passed to audit_log_*() functions, audit_log_*()
functions return immediately in case of a NULL audit buffer argument.

It is not necessary for audit_log_*() functions to be called with
NULL audit buffer argument, so return early when audit_log_start()
returns NULL.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 security/integrity/integrity_audit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
index 29220056207f..fbc032185d72 100644
--- a/security/integrity/integrity_audit.c
+++ b/security/integrity/integrity_audit.c
@@ -45,6 +45,8 @@ void integrity_audit_message(int audit_msgno, struct inode *inode,
 		return;
 
 	ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno);
+	if (unlikely(!ab))
+		return;
 	audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
 			 task_pid_nr(current),
 			 from_kuid(&init_user_ns, current_uid()),
-- 
2.30.0


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

* Re: [PATCH -next] integrity: return early if audit_log_start return NULL
  2021-10-09  6:30 [PATCH -next] integrity: return early if audit_log_start return NULL Gaosheng Cui
@ 2021-10-12 14:15 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2021-10-12 14:15 UTC (permalink / raw)
  To: Gaosheng Cui
  Cc: James Morris, Serge Hallyn, linux-security-module, linux-kernel,
	xiujianfeng, wangweiyang2

On Sat, Oct 9, 2021 at 2:28 AM Gaosheng Cui <cuigaosheng1@huawei.com> wrote:
>
> audit_log_start() may return NULL in below cases:
>   - when audit is not initialized.
>   - when audit backlog limit exceeds.
>
> After the call to audit_log_start() is made and then possible NULL audit
> buffer argument is passed to audit_log_*() functions, audit_log_*()
> functions return immediately in case of a NULL audit buffer argument.
>
> It is not necessary for audit_log_*() functions to be called with
> NULL audit buffer argument, so return early when audit_log_start()
> returns NULL.
>
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  security/integrity/integrity_audit.c | 2 ++
>  1 file changed, 2 insertions(+)

Acked-by: Paul Moore <paul@paul-moore.com>

> diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
> index 29220056207f..fbc032185d72 100644
> --- a/security/integrity/integrity_audit.c
> +++ b/security/integrity/integrity_audit.c
> @@ -45,6 +45,8 @@ void integrity_audit_message(int audit_msgno, struct inode *inode,
>                 return;
>
>         ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno);
> +       if (unlikely(!ab))
> +               return;
>         audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
>                          task_pid_nr(current),
>                          from_kuid(&init_user_ns, current_uid()),
> --
> 2.30.0

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2021-10-12 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09  6:30 [PATCH -next] integrity: return early if audit_log_start return NULL Gaosheng Cui
2021-10-12 14:15 ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.