Skip to content

Commit b50eba7

Browse files
rgbriggseparis
authored andcommitted
audit: format user messages to size of MAX_AUDIT_MESSAGE_LENGTH
Messages of type AUDIT_USER_TTY were being formatted to 1024 octets, truncating messages approaching MAX_AUDIT_MESSAGE_LENGTH (8970 octets). Set the formatting to 8560 characters, given maximum estimates for prefix and suffix budgets. See the problem discussion: https://www.redhat.com/archives/linux-audit/2009-January/msg00030.html And the new size rationale: https://www.redhat.com/archives/linux-audit/2013-September/msg00016.html Test ~8k messages with: auditctl -m "$(for i in $(seq -w 001 820);do echo -n "${i}0______";done)" Reported-by: LC Bruzenak <lenny@magitekltd.com> Reported-by: Justin Stephenson <jstephen@redhat.com> Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 6e46645 commit b50eba7

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎include/uapi/linux/audit.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ enum {
358358
#define AUDIT_PERM_READ 4
359359
#define AUDIT_PERM_ATTR 8
360360

361+
/* MAX_AUDIT_MESSAGE_LENGTH is set in audit:lib/libaudit.h as:
362+
* 8970 // PATH_MAX*2+CONTEXT_SIZE*2+11+256+1
363+
* max header+body+tailer: 44 + 29 + 32 + 262 + 7 + pad
364+
*/
365+
#define AUDIT_MESSAGE_TEXT_MAX 8560
366+
361367
struct audit_status {
362368
__u32 mask; /* Bit mask for valid entries */
363369
__u32 enabled; /* 1 = enabled, 0 = disabled */

‎kernel/audit.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
715715
}
716716
audit_log_common_recv_msg(&ab, msg_type);
717717
if (msg_type != AUDIT_USER_TTY)
718-
audit_log_format(ab, " msg='%.1024s'",
718+
audit_log_format(ab, " msg='%.*s'",
719+
AUDIT_MESSAGE_TEXT_MAX,
719720
(char *)data);
720721
else {
721722
int size;

0 commit comments

Comments
 (0)