Skip to contentSkip to conversation

audit: ignore terminating NUL in AUDIT_USER_TTY messages

PATCH New Miloslav Trmac 1 participant 1 message Mar 19, 2009 1 message not in the archive Audit

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 573973171.1703051237470609326.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH 1/1 audit: ignore terminating NUL in AUDIT_USER_TTY messages

Hello,
this appears to have been lost somewhere...
Mirek

From: Miloslav Trmac <[email protected]>

AUDIT_USER_TTY, like all other messages sent from user-space, is sent NUL-terminated. Unlike other user-space audit messages, which come only from trusted sources, AUDIT_USER_TTY messages are processed using audit_log_n_untrustedstring().

This patch modifies AUDIT_USER_TTY handling to ignore the trailing NUL and use the "quoted_string" representation of the message if possible.

---

 kernel/audit.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/audit.c renamed from kernel/audit.c~audit-ignore-terminating-nul-in-audit_user_tty-messages +3 -0
diff -puN kernel/audit.c~audit-ignore-terminating-nul-in-audit_user_tty-messages kernel/audit.c
@@ -763,6 +763,9 @@ static int audit_receive_msg(struct sk_b
 
 				audit_log_format(ab, " msg=");
 				size = nlmsg_len(nlh);
+				if (size > 0 &&
+				    ((unsigned char *)data)[size - 1] == '\0')
+					size--;
 				audit_log_n_untrustedstring(ab, data, size);
 			}
 			audit_set_pid(ab, pid);

_