mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 00:20:08 +07:00
2f845882ec
Error code is not included in the audit messages logged by the integrity subsystem. Define a new function integrity_audit_message() that takes error code in the "errno" parameter. Add "errno" field in the audit messages logged by the integrity subsystem and set the value passed in the "errno" parameter. [ 6.303048] audit: type=1804 audit(1592506281.627:2): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel op=measuring_key cause=ENOMEM comm="swapper/0" name=".builtin_trusted_keys" res=0 errno=-12 [ 7.987647] audit: type=1802 audit(1592506283.312:9): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=policy_update cause=completed comm="systemd" res=1 errno=0 [ 8.019432] audit: type=1804 audit(1592506283.344:10): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=measuring_kexec_cmdline cause=hashing_error comm="systemd" name="kexec-cmdline" res=0 errno=-22 Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com> Suggested-by: Steve Grubb <sgrubb@redhat.com> Suggested-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
68 lines
1.9 KiB
C
68 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2008 IBM Corporation
|
|
* Author: Mimi Zohar <zohar@us.ibm.com>
|
|
*
|
|
* File: integrity_audit.c
|
|
* Audit calls for the integrity subsystem
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/audit.h>
|
|
#include "integrity.h"
|
|
|
|
static int integrity_audit_info;
|
|
|
|
/* ima_audit_setup - enable informational auditing messages */
|
|
static int __init integrity_audit_setup(char *str)
|
|
{
|
|
unsigned long audit;
|
|
|
|
if (!kstrtoul(str, 0, &audit))
|
|
integrity_audit_info = audit ? 1 : 0;
|
|
return 1;
|
|
}
|
|
__setup("integrity_audit=", integrity_audit_setup);
|
|
|
|
void integrity_audit_msg(int audit_msgno, struct inode *inode,
|
|
const unsigned char *fname, const char *op,
|
|
const char *cause, int result, int audit_info)
|
|
{
|
|
integrity_audit_message(audit_msgno, inode, fname, op, cause,
|
|
result, audit_info, 0);
|
|
}
|
|
|
|
void integrity_audit_message(int audit_msgno, struct inode *inode,
|
|
const unsigned char *fname, const char *op,
|
|
const char *cause, int result, int audit_info,
|
|
int errno)
|
|
{
|
|
struct audit_buffer *ab;
|
|
char name[TASK_COMM_LEN];
|
|
|
|
if (!integrity_audit_info && audit_info == 1) /* Skip info messages */
|
|
return;
|
|
|
|
ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno);
|
|
audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
|
|
task_pid_nr(current),
|
|
from_kuid(&init_user_ns, current_cred()->uid),
|
|
from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
|
audit_get_sessionid(current));
|
|
audit_log_task_context(ab);
|
|
audit_log_format(ab, " op=%s cause=%s comm=", op, cause);
|
|
audit_log_untrustedstring(ab, get_task_comm(name, current));
|
|
if (fname) {
|
|
audit_log_format(ab, " name=");
|
|
audit_log_untrustedstring(ab, fname);
|
|
}
|
|
if (inode) {
|
|
audit_log_format(ab, " dev=");
|
|
audit_log_untrustedstring(ab, inode->i_sb->s_id);
|
|
audit_log_format(ab, " ino=%lu", inode->i_ino);
|
|
}
|
|
audit_log_format(ab, " res=%d errno=%d", !result, errno);
|
|
audit_log_end(ab);
|
|
}
|