Skip to contentSkip to conversation

audit: log the audit_names record type

PATCH Superseded Jeff Layton 2 participants 4 messages May 8, 2013 – May 23, 2013 Audit

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audit: log the audit_names record type

...to make it clear what the intent behind each record's operation was.

In many cases you can infer this, based on the context of the syscall and the result. In other cases it's not so obvious. For instance, in the case where you have a file being renamed over another, you'll have two different records with the same filename but different inode info. By logging this information we can clearly tell which one was created and which was deleted.

---
 kernel/auditsc.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
kernel/auditsc.c +20 -0
index 8d87439..4f90536 100644
@@ -1575,6 +1575,26 @@ static void audit_log_name(struct audit_context *context, struct audit_names *n,
 		}
 	}
 
+	/* log the audit_names record type */
+	audit_log_format(ab, " nametype=");
+	switch(n->type) {
+	case AUDIT_TYPE_NORMAL:
+		audit_log_format(ab, "NORMAL");
+		break;
+	case AUDIT_TYPE_PARENT:
+		audit_log_format(ab, "PARENT");
+		break;
+	case AUDIT_TYPE_CHILD_DELETE:
+		audit_log_format(ab, "DELETE");
+		break;
+	case AUDIT_TYPE_CHILD_CREATE:
+		audit_log_format(ab, "CREATE");
+		break;
+	default:
+		audit_log_format(ab, "UNKNOWN");
+		break;
+	}
+
 	audit_log_fcaps(ab, n);
 
 	audit_log_end(ab);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · Jeff Layton

...to make it clear what the intent behind each record's operation was.

In many cases you can infer this, based on the context of the syscall and the result. In other cases it's not so obvious. For instance, in the case where you have a file being renamed over another, you'll have two different records with the same filename but different inode info. By logging this information we can clearly tell which one was created and which was deleted.

Space is generally at a premium. Every byte counts. Rather than print strings, which we usually avoid, it might be better to just print the number and let user space convert that to something readable.

All of these records are to point out what the object of the syscall is. And my understanding is that these labels are to describe the action or operation being performed. So, maybe naming the field "objact=" or "objop=" would save a couple bytes?

-Steve

Quoted 36 lines
---
 kernel/auditsc.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
kernel/auditsc.c +20 -0
index 8d87439..4f90536 100644
@@ -1575,6 +1575,26 @@ static void audit_log_name(struct audit_context
 *context, struct audit_names *n, }
 	}
 
+	/* log the audit_names record type */
+	audit_log_format(ab, " nametype=");
+	switch(n->type) {
+	case AUDIT_TYPE_NORMAL:
+		audit_log_format(ab, "NORMAL");
+		break;
+	case AUDIT_TYPE_PARENT:
+		audit_log_format(ab, "PARENT");
+		break;
+	case AUDIT_TYPE_CHILD_DELETE:
+		audit_log_format(ab, "DELETE");
+		break;
+	case AUDIT_TYPE_CHILD_CREATE:
+		audit_log_format(ab, "CREATE");
+		break;
+	default:
+		audit_log_format(ab, "UNKNOWN");
+		break;
+	}
+
 	audit_log_fcaps(ab, n);
 
 	audit_log_end(ab);
#2 lore raw
Quoted 56 lines · On Thu, 09 May 2013 09:21:50 -0400 Steve Grubb <[email protected]> wrote:
Quoted 8 lines · Jeff Layton

...to make it clear what the intent behind each record's operation was.

In many cases you can infer this, based on the context of the syscall and the result. In other cases it's not so obvious. For instance, in the case where you have a file being renamed over another, you'll have two different records with the same filename but different inode info. By logging this information we can clearly tell which one was created and which was deleted.

Space is generally at a premium. Every byte counts. Rather than print strings, which we usually avoid, it might be better to just print the number and let user space convert that to something readable.

All of these records are to point out what the object of the syscall is. And my understanding is that these labels are to describe the action or operation being performed. So, maybe naming the field "objact=" or "objop=" would save a couple bytes?

-Steve

Quoted 35 lines
---
 kernel/auditsc.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
kernel/auditsc.c +20 -0
index 8d87439..4f90536 100644
@@ -1575,6 +1575,26 @@ static void audit_log_name(struct audit_context
 *context, struct audit_names *n, }
 	}
 
+	/* log the audit_names record type */
+	audit_log_format(ab, " nametype=");
+	switch(n->type) {
+	case AUDIT_TYPE_NORMAL:
+		audit_log_format(ab, "NORMAL");
+		break;
+	case AUDIT_TYPE_PARENT:
+		audit_log_format(ab, "PARENT");
+		break;
+	case AUDIT_TYPE_CHILD_DELETE:
+		audit_log_format(ab, "DELETE");
+		break;
+	case AUDIT_TYPE_CHILD_CREATE:
+		audit_log_format(ab, "CREATE");
+		break;
+	default:
+		audit_log_format(ab, "UNKNOWN");
+		break;
+	}
+
 	audit_log_fcaps(ab, n);
 
Quoted 1 line

kernel/auditsc.c static void audit_log_name(struct audit_context · line 1600

Quoted 1 line
kernel/auditsc.c +0 -0
 	audit_log_end(ab);

The numerical values of these types is an implementation detail in a private kernel header. I don't think we really want to expose those values to userland.

How about something like this instead?

--------------------[snip]------------------

[PATCH] audit: log the audit_names record type

...to make it clear what the intent behind each record's operation was.

In many cases you can infer this, based on the context of the syscall and the result. In other cases it's not so obvious. For instance, in the case where you have a file being renamed over another, you'll have two different records with the same filename but different inode info. By logging this information we can clearly tell which one was created and which was deleted.

---
 kernel/auditsc.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
kernel/auditsc.c +20 -0
index 8d87439..0e44eec 100644
@@ -1575,6 +1575,26 @@ static void audit_log_name(struct audit_context *context, struct audit_names *n,
 		}
 	}
 
+	/* log the audit_names record type */
+	audit_log_format(ab, " objact=");
+	switch(n->type) {
+	case AUDIT_TYPE_NORMAL:
+		audit_log_format(ab, "N");
+		break;
+	case AUDIT_TYPE_PARENT:
+		audit_log_format(ab, "P");
+		break;
+	case AUDIT_TYPE_CHILD_DELETE:
+		audit_log_format(ab, "D");
+		break;
+	case AUDIT_TYPE_CHILD_CREATE:
+		audit_log_format(ab, "C");
+		break;
+	default:
+		audit_log_format(ab, "U");
+		break;
+	}
+
 	audit_log_fcaps(ab, n);
 
 	audit_log_end(ab);
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 1/1 audit: log the audit_names record type

In reply to Jeff Layton

...to make it clear what the intent behind each record's operation was.

In many cases you can infer this, based on the context of the syscall and the result. In other cases it's not so obvious. For instance, in the case where you have a file being renamed over another, you'll have two different records with the same filename but different inode info. By logging this information we can clearly tell which one was created and which was deleted.

---
 kernel/audit.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
kernel/audit.c +20 -0
index 21c7fa6..d0cd77d 100644
@@ -1535,6 +1535,26 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
 		}
 	}
 
+	/* log the audit_names record type */
+	audit_log_format(ab, " objtype=");
+	switch(n->type) {
+	case AUDIT_TYPE_NORMAL:
+		audit_log_format(ab, "NORMAL");
+		break;
+	case AUDIT_TYPE_PARENT:
+		audit_log_format(ab, "PARENT");
+		break;
+	case AUDIT_TYPE_CHILD_DELETE:
+		audit_log_format(ab, "DELETE");
+		break;
+	case AUDIT_TYPE_CHILD_CREATE:
+		audit_log_format(ab, "CREATE");
+		break;
+	default:
+		audit_log_format(ab, "UNKNOWN");
+		break;
+	}
+
 	audit_log_fcaps(ab, n);
 	audit_log_end(ab);
 }
Signature · 1 line
1.7.1