Syscall auditing - move "name=" field to the end
PATCH 1/1 Syscall auditing - move "name=" field to the end
This patch moves the "name=" field to the end of audit records. The original placement is bad because it cannot be properly parsed. It is impossible to tell if the name is "/bin/true" or "/bin/true inode=469634 dev=00:00" because the "inode=" and "dev=" fields can be omitted.
Before:
audit(1111008486.824:89346): item=0 name=/bin/true inode=469634 dev=00:00
After:
audit(1111008486.824:89346): item=0 inode=469634 dev=00:00 name=/bin/true
Signature · 1 line
Ondrej Zary
kernel/auditsc.c renamed from kernel/auditsc.c~ +3 -3
@@ -612,9 +612,6 @@if (!ab)continue ;/* audit_panic has been called */ audit_log_format (ab,"item=%d" , i); -if (context->names[i].name) -audit_log_format (ab," name=%s" , - context->names[i].name);if (context->names[i].ino != (unsigned long )-1 )audit_log_format (ab," inode=%lu" , context->names[i].ino);
@@ -624,6 +621,9 @@audit_log_format (ab," dev=%02x:%02x" ,MAJOR (context->names[i].rdev),MINOR (context->names[i].rdev)); +if (context->names[i].name) +audit_log_format (ab," name=%s" , + context->names[i].name);audit_log_end (ab); } }
Quoted 5 lines · * Ondrej Zary ([email protected]) wrote:
This patch moves the "name=" field to the end of audit records. The original placement is bad because it cannot be properly parsed. It is impossible to tell if the name is "
/bin/true" or "/bin/trueinode=469634 dev=00:00" because the "inode=" and "dev=" fields can be omitted.
Quoted 7 lines
Before:
audit(1111008486.824:89346): item=0 name=/bin/true inode=469634 dev=00:00After:
audit(1111008486.824:89346): item=0 inode=469634 dev=00:00 name=/bin/trueSigned-off-by Ondrej Zary <[email protected]>
Looks reasonable. Thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 5 lines · Chris Wright
Quoted 4 lines · * Ondrej Zary ([email protected]) wrote:
This patch moves the "name=" field to the end of audit records. The original placement is bad because it cannot be properly parsed. It is impossible to tell if the name is "
/bin/true" or "/bin/trueinode=469634 dev=00:00" because the "inode=" and "dev=" fields can be omitted.
Consider:
open("/bin/true\naudit(1111008484.824:89346): ...", O_RDONLY);
I don't think this patch is enough -- either we need to escape the text completely or just dump it as hex instead of a string. One option would be to dump it in quotes as a string if all chars in the string are in the range 0x20-0x7e, and as hex otherwise. That slightly complicates the parsing, but not by much, and still gives you plain text in the majority of cases while protecting against abuse.
Signature · 1 line
dwmw2
Quoted 9 lines · * David Woodhouse ([email protected]) wrote:
Quoted 5 lines · Chris Wright
Quoted 4 lines · * Ondrej Zary ([email protected]) wrote:
This patch moves the "name=" field to the end of audit records. The original placement is bad because it cannot be properly parsed. It is impossible to tell if the name is "
/bin/true" or "/bin/trueinode=469634 dev=00:00" because the "inode=" and "dev=" fields can be omitted.Consider:
Quoted 8 lines
open("/bin/true\naudit(1111008484.824:89346): ...", O_RDONLY);I don't think this patch is enough -- either we need to escape the text completely or just dump it as hex instead of a string. One option would be to dump it in quotes as a string if all chars in the string are in the range 0x20-0x7e, and as hex otherwise. That slightly complicates the parsing, but not by much, and still gives you plain text in the majority of cases while protecting against abuse.
Yes good point. I don't have a strong preference. Steve, are you working on processing log data, do you have a preference?
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 1 line · Chris Wright
Steve, are you working on processing log data, do you have a preference?
Yes, I am working on a utility to process the data. I have 4 comments:
1) Fields that magically appear and dissappear are problematic for fast parsing.
2) There should be a way to control what fields the kernel emits. The dissappearing fields are what I take to be a stab at message compression. By having a mask driven approach and always emitting those fields, we can parse faster and have compression.
3) Fields that potentially have a space, tab, or carriage return in them need escaping or quoting if they are sent in human readable format.
4) There should be a mode/format status variable so that in the future we can tell the kernel to switch to another (binary) format. This way human readable records can go to syslog and special apps like the audit daemon can switch to another format (binary data ?) which might be more efficient. I haven't spent anytime looking at what makes sense for a binary format, nor do we have time for that right now. But I'd like to look at that in the future.
-Steve Grubb