linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] integrity: check the return value of audit_log_start()
@ 2022-01-14  4:23 xkernel.wang
  2022-01-14 22:13 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: xkernel.wang @ 2022-01-14  4:23 UTC (permalink / raw)
  To: paul, jmorris, serge; +Cc: linux-security-module, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

audit_log_start() returns audit_buffer pointer on success or NULL on
error, so it is better to check the return value of it.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
Changelogs: simplify the patch. 
Note: Take the suggestion from Paul Moore.
 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 2922005..0ec5e4c 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 (!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()),
-- 

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

* Re: [PATCHv2] integrity: check the return value of audit_log_start()
  2022-01-14  4:23 [PATCHv2] integrity: check the return value of audit_log_start() xkernel.wang
@ 2022-01-14 22:13 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2022-01-14 22:13 UTC (permalink / raw)
  To: xkernel.wang; +Cc: jmorris, serge, linux-security-module, linux-kernel

On Thu, Jan 13, 2022 at 11:24 PM <xkernel.wang@foxmail.com> wrote:
>
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
>
> audit_log_start() returns audit_buffer pointer on success or NULL on
> error, so it is better to check the return value of it.
>
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>

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

> ---
> Changelogs: simplify the patch.
> Note: Take the suggestion from Paul Moore.
>  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 2922005..0ec5e4c 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 (!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()),
> --

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2022-01-14 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  4:23 [PATCHv2] integrity: check the return value of audit_log_start() xkernel.wang
2022-01-14 22:13 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).