Skip to content

Commit

Permalink
audit: format user messages to size of MAX_AUDIT_MESSAGE_LENGTH
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Justin Stephenson <[email protected]>
Signed-off-by: Richard Guy Briggs <[email protected]>
Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
rgbriggs authored and eparis committed Nov 5, 2013
1 parent 6e46645 commit b50eba7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/uapi/linux/audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ enum {
#define AUDIT_PERM_READ 4
#define AUDIT_PERM_ATTR 8

/* MAX_AUDIT_MESSAGE_LENGTH is set in audit:lib/libaudit.h as:
* 8970 // PATH_MAX*2+CONTEXT_SIZE*2+11+256+1
* max header+body+tailer: 44 + 29 + 32 + 262 + 7 + pad
*/
#define AUDIT_MESSAGE_TEXT_MAX 8560

struct audit_status {
__u32 mask; /* Bit mask for valid entries */
__u32 enabled; /* 1 = enabled, 0 = disabled */
Expand Down
3 changes: 2 additions & 1 deletion kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
}
audit_log_common_recv_msg(&ab, msg_type);
if (msg_type != AUDIT_USER_TTY)
audit_log_format(ab, " msg='%.1024s'",
audit_log_format(ab, " msg='%.*s'",
AUDIT_MESSAGE_TEXT_MAX,
(char *)data);
else {
int size;
Expand Down

0 comments on commit b50eba7

Please sign in to comment.