Skip to content

Commit 2f84588

Browse files
nramasmimizohar
authored andcommitted
integrity: Add errno field in audit message
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 <[email protected]> Suggested-by: Steve Grubb <[email protected]> Suggested-by: Mimi Zohar <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 20c59ce commit 2f84588

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

security/integrity/integrity.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
239239
const unsigned char *fname, const char *op,
240240
const char *cause, int result, int info);
241241

242+
void integrity_audit_message(int audit_msgno, struct inode *inode,
243+
const unsigned char *fname, const char *op,
244+
const char *cause, int result, int info,
245+
int errno);
246+
242247
static inline struct audit_buffer *
243248
integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
244249
{
@@ -253,6 +258,14 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode,
253258
{
254259
}
255260

261+
static inline void integrity_audit_message(int audit_msgno,
262+
struct inode *inode,
263+
const unsigned char *fname,
264+
const char *op, const char *cause,
265+
int result, int info, int errno)
266+
{
267+
}
268+
256269
static inline struct audit_buffer *
257270
integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type)
258271
{

security/integrity/integrity_audit.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ __setup("integrity_audit=", integrity_audit_setup);
2828
void integrity_audit_msg(int audit_msgno, struct inode *inode,
2929
const unsigned char *fname, const char *op,
3030
const char *cause, int result, int audit_info)
31+
{
32+
integrity_audit_message(audit_msgno, inode, fname, op, cause,
33+
result, audit_info, 0);
34+
}
35+
36+
void integrity_audit_message(int audit_msgno, struct inode *inode,
37+
const unsigned char *fname, const char *op,
38+
const char *cause, int result, int audit_info,
39+
int errno)
3140
{
3241
struct audit_buffer *ab;
3342
char name[TASK_COMM_LEN];
@@ -53,6 +62,6 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
5362
audit_log_untrustedstring(ab, inode->i_sb->s_id);
5463
audit_log_format(ab, " ino=%lu", inode->i_ino);
5564
}
56-
audit_log_format(ab, " res=%d", !result);
65+
audit_log_format(ab, " res=%d errno=%d", !result, errno);
5766
audit_log_end(ab);
5867
}

0 commit comments

Comments
 (0)