aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmac <mitr@redhat.com>2009-03-19 09:48:27 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-04-05 13:43:24 -0400
commitb3897f567100d18e0597f638b911d23aa5e0dd23 (patch)
tree32fa9d3d8faaae7a87de64163d450460b423fd87
parentc28bb7da74ab74a2860d652493aaff7de104d79e (diff)
Audit: fix handling of 'strings' with NULL characters
currently audit_log_n_untrustedstring() uses audit_string_contains_control() to check if the 'string' has any control characters. If the 'string' has an embedded NULL audit_string_contains_control() will return that the data has no control characters and will then pass the string to audit_log_n_string with the total length, not the length up to the first NULL. audit_log_n_string() does a memcpy of the entire length and so the actual audit record emitted may then contain a NULL and then whatever random memory is after the NULL. Since we want to log the entire octet stream (if we can't trust the data to be a string we can't trust that a NULL isn't actually a part of it) we should just consider NULL as a control character. If the caller is certain they want to stop at the first NULL they should be using audit_log_untrustedstring. Signed-off-by: Eric Paris <eparis@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--kernel/audit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index ce6d8ea3131e..fa3805516dff 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1382,7 +1382,7 @@ void audit_log_n_string(struct audit_buffer *ab, const char *string,
1382int audit_string_contains_control(const char *string, size_t len) 1382int audit_string_contains_control(const char *string, size_t len)
1383{ 1383{
1384 const unsigned char *p; 1384 const unsigned char *p;
1385 for (p = string; p < (const unsigned char *)string + len && *p; p++) { 1385 for (p = string; p < (const unsigned char *)string + len; p++) {
1386 if (*p == '"' || *p < 0x21 || *p > 0x7e) 1386 if (*p == '"' || *p < 0x21 || *p > 0x7e)
1387 return 1; 1387 return 1;
1388 } 1388 }