diff mbox series

[v4] integrity: check the return value of audit_log_start()

Message ID tencent_0685FF3C104366D05C368E2E0A88F043A507@qq.com (mailing list archive)
State New, archived
Headers show
Series [v4] integrity: check the return value of audit_log_start() | expand

Commit Message

Xiaoke Wang Jan. 27, 2022, 1:59 a.m. UTC
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:
V3 -> V4: update the mail list.
V2 -> V3: add the Reviewed-by tag.
V1 -> V2: simplify the patch.
security/integrity/integrity_audit.c | 2 ++
1 file changed, 2 insertions(+)

--

Comments

Mimi Zohar Jan. 27, 2022, 2:19 a.m. UTC | #1
Hi Xiaoke,

On Thu, 2022-01-27 at 09:59 +0800, Xiaoke Wang 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>

Thanks, this patch is staged in the next-integrity-testing branch 
https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git/

Mimi
diff mbox series

Patch

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()),