aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2009-01-09 10:44:16 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-04-05 13:38:59 -0400
commitca96a895a6bae7efe7b11a35d9f43e6228467562 (patch)
treef0a838bddc4d20b204720592811484bbe3e98a6a
parent6bb597507f9839b13498781e481f5458aea33620 (diff)
audit: EXECVE record - removed bogus newline
(updated) Added hunk that changes the comment, the rest is the same. EXECVE records contain a newline after every argument. auditd converts "\n" to " " so you cannot see newlines even in raw logs, but they're there nevertheless. If you're not using auditd, you need to work round them. These '\n' chars are can be easily replaced by spaces when creating record in kernel. Note there is no need for trailing '\n' in an audit record. record before this patch: "type=EXECVE msg=audit(1231421801.566:31): argc=4 a0=\"./test\"\na1=\"a\"\na2=\"b\"\na3=\"c\"\n" record after this patch: "type=EXECVE msg=audit(1231421801.566:31): argc=4 a0=\"./test\" a1=\"a\" a2=\"b\" a3=\"c\"" Signed-off-by: Jiri Pirko <jpirko@redhat.com> Acked-by: Eric Paris <eparis@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--kernel/auditsc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 2bfc64786765..738c03695b79 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1024,7 +1024,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
1024{ 1024{
1025 char arg_num_len_buf[12]; 1025 char arg_num_len_buf[12];
1026 const char __user *tmp_p = p; 1026 const char __user *tmp_p = p;
1027 /* how many digits are in arg_num? 3 is the length of a=\n */ 1027 /* how many digits are in arg_num? 3 is the length of " a=" */
1028 size_t arg_num_len = snprintf(arg_num_len_buf, 12, "%d", arg_num) + 3; 1028 size_t arg_num_len = snprintf(arg_num_len_buf, 12, "%d", arg_num) + 3;
1029 size_t len, len_left, to_send; 1029 size_t len, len_left, to_send;
1030 size_t max_execve_audit_len = MAX_EXECVE_AUDIT_LEN; 1030 size_t max_execve_audit_len = MAX_EXECVE_AUDIT_LEN;
@@ -1110,7 +1110,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
1110 * so we can be sure nothing was lost. 1110 * so we can be sure nothing was lost.
1111 */ 1111 */
1112 if ((i == 0) && (too_long)) 1112 if ((i == 0) && (too_long))
1113 audit_log_format(*ab, "a%d_len=%zu ", arg_num, 1113 audit_log_format(*ab, " a%d_len=%zu", arg_num,
1114 has_cntl ? 2*len : len); 1114 has_cntl ? 2*len : len);
1115 1115
1116 /* 1116 /*
@@ -1130,7 +1130,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
1130 buf[to_send] = '\0'; 1130 buf[to_send] = '\0';
1131 1131
1132 /* actually log it */ 1132 /* actually log it */
1133 audit_log_format(*ab, "a%d", arg_num); 1133 audit_log_format(*ab, " a%d", arg_num);
1134 if (too_long) 1134 if (too_long)
1135 audit_log_format(*ab, "[%d]", i); 1135 audit_log_format(*ab, "[%d]", i);
1136 audit_log_format(*ab, "="); 1136 audit_log_format(*ab, "=");
@@ -1138,7 +1138,6 @@ static int audit_log_single_execve_arg(struct audit_context *context,
1138 audit_log_n_hex(*ab, buf, to_send); 1138 audit_log_n_hex(*ab, buf, to_send);
1139 else 1139 else
1140 audit_log_format(*ab, "\"%s\"", buf); 1140 audit_log_format(*ab, "\"%s\"", buf);
1141 audit_log_format(*ab, "\n");
1142 1141
1143 p += to_send; 1142 p += to_send;
1144 len_left -= to_send; 1143 len_left -= to_send;
@@ -1166,7 +1165,7 @@ static void audit_log_execve_info(struct audit_context *context,
1166 1165
1167 p = (const char __user *)axi->mm->arg_start; 1166 p = (const char __user *)axi->mm->arg_start;
1168 1167
1169 audit_log_format(*ab, "argc=%d ", axi->argc); 1168 audit_log_format(*ab, "argc=%d", axi->argc);
1170 1169
1171 /* 1170 /*
1172 * we need some kernel buffer to hold the userspace args. Just 1171 * we need some kernel buffer to hold the userspace args. Just