Skip to content

Commit 51cc83f

Browse files
rgbriggseparis
authored andcommitted
audit: add audit_backlog_wait_time configuration option
reaahead-collector abuses the audit logging facility to discover which files are accessed at boot time to make a pre-load list Add a tuning option to audit_backlog_wait_time so that if auditd can't keep up, or gets blocked, the callers won't be blocked. Bump audit_status API version to "2". Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 09f883a commit 51cc83f

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎include/uapi/linux/audit.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ enum {
319319
#define AUDIT_STATUS_PID 0x0004
320320
#define AUDIT_STATUS_RATE_LIMIT 0x0008
321321
#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
322+
#define AUDIT_STATUS_BACKLOG_WAIT_TIME 0x0020
322323
/* Failure-to-log actions */
323324
#define AUDIT_FAIL_SILENT 0
324325
#define AUDIT_FAIL_PRINTK 1
@@ -377,6 +378,7 @@ struct audit_status {
377378
__u32 lost; /* messages lost */
378379
__u32 backlog; /* messages waiting in queue */
379380
__u32 version; /* audit api version number */
381+
__u32 backlog_wait_time;/* message queue wait timeout */
380382
};
381383

382384
struct audit_features {

‎kernel/audit.c‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ static int audit_set_backlog_limit(int limit)
334334
return audit_do_config_change("audit_backlog_limit", &audit_backlog_limit, limit);
335335
}
336336

337+
static int audit_set_backlog_wait_time(int timeout)
338+
{
339+
return audit_do_config_change("audit_backlog_wait_time",
340+
&audit_backlog_wait_time, timeout);
341+
}
342+
337343
static int audit_set_enabled(int state)
338344
{
339345
int rc;
@@ -778,7 +784,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
778784
s.backlog_limit = audit_backlog_limit;
779785
s.lost = atomic_read(&audit_lost);
780786
s.backlog = skb_queue_len(&audit_skb_queue);
781-
s.version = 1;
787+
s.version = 2;
788+
s.backlog_wait_time = audit_backlog_wait_time;
782789
audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
783790
&s, sizeof(s));
784791
break;
@@ -812,8 +819,28 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
812819
if (err < 0)
813820
return err;
814821
}
815-
if (s.mask & AUDIT_STATUS_BACKLOG_LIMIT)
822+
if (s.mask & AUDIT_STATUS_BACKLOG_LIMIT) {
816823
err = audit_set_backlog_limit(s.backlog_limit);
824+
if (err < 0)
825+
return err;
826+
}
827+
switch (s.version) {
828+
/* add future vers # cases immediately below and allow
829+
* to fall through */
830+
case 2:
831+
if (s.mask & AUDIT_STATUS_BACKLOG_WAIT_TIME) {
832+
if (sizeof(s) > (size_t)nlh->nlmsg_len)
833+
return -EINVAL;
834+
if (s.backlog_wait_time < 0 ||
835+
s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
836+
return -EINVAL;
837+
err = audit_set_backlog_wait_time(s.backlog_wait_time);
838+
if (err < 0)
839+
return err;
840+
}
841+
default:
842+
break;
843+
}
817844
break;
818845
}
819846
case AUDIT_GET_FEATURE:

0 commit comments

Comments
 (0)