Skip to content

Commit 92c82e8

Browse files
rgbriggspcmoore
authored andcommitted
audit: add feature audit_lost reset
Add a method to reset the audit_lost value. An AUDIT_SET message with the AUDIT_STATUS_LOST flag set by itself will return a positive value repesenting the current audit_lost value and reset the counter to zero. If AUDIT_STATUS_LOST is not the only flag set, the reset command will be ignored. The value sent with the command is ignored. The return value will be the +ve lost value at reset time. An AUDIT_CONFIG_CHANGE message will be queued to the listening audit daemon. The message will be a standard CONFIG_CHANGE message with the fields "lost=0" and "old=" with the latter containing the value of audit_lost at reset time. See: linux-audit/audit-kernel#3 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Acked-by: Steve Grubb <sgrubb@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 89670af commit 92c82e8

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎include/uapi/linux/audit.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,19 @@ enum {
326326
#define AUDIT_STATUS_RATE_LIMIT 0x0008
327327
#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
328328
#define AUDIT_STATUS_BACKLOG_WAIT_TIME 0x0020
329+
#define AUDIT_STATUS_LOST 0x0040
329330

330331
#define AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT 0x00000001
331332
#define AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME 0x00000002
332333
#define AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH 0x00000004
333334
#define AUDIT_FEATURE_BITMAP_SESSIONID_FILTER 0x00000010
335+
#define AUDIT_FEATURE_BITMAP_LOST_RESET 0x00000020
336+
334337
#define AUDIT_FEATURE_BITMAP_ALL (AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT | \
335338
AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME | \
336339
AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH | \
337-
AUDIT_FEATURE_BITMAP_SESSIONID_FILTER)
340+
AUDIT_FEATURE_BITMAP_SESSIONID_FILTER | \
341+
AUDIT_FEATURE_BITMAP_LOST_RESET)
338342

339343
/* deprecated: AUDIT_VERSION_* */
340344
#define AUDIT_VERSION_LATEST AUDIT_FEATURE_BITMAP_ALL

‎kernel/audit.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ u32 audit_sig_sid = 0;
121121
3) suppressed due to audit_rate_limit
122122
4) suppressed due to audit_backlog_limit
123123
*/
124-
static atomic_t audit_lost = ATOMIC_INIT(0);
124+
static atomic_t audit_lost = ATOMIC_INIT(0);
125125

126126
/* The netlink socket. */
127127
static struct sock *audit_sock;
@@ -1052,6 +1052,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
10521052
if (err < 0)
10531053
return err;
10541054
}
1055+
if (s.mask == AUDIT_STATUS_LOST) {
1056+
u32 lost = atomic_xchg(&audit_lost, 0);
1057+
1058+
audit_log_config_change("lost", 0, lost, 1);
1059+
return lost;
1060+
}
10551061
break;
10561062
}
10571063
case AUDIT_GET_FEATURE:

0 commit comments

Comments
 (0)