Skip to content

Commit a09cfa4

Browse files
committed
audit: don't ever sleep on a command record/message
Sleeping on a command record/message in audit_log_start() could slow something, e.g. auditd, from doing something important, e.g. clean shutdown, which could present problems on a heavily loaded system. This patch allows tasks to bypass any queue restrictions if they are logging a command record/message. Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 6c54e78 commit a09cfa4

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎kernel/audit.c‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,11 +1488,19 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
14881488
if (unlikely(!audit_filter(type, AUDIT_FILTER_TYPE)))
14891489
return NULL;
14901490

1491-
/* don't ever fail/sleep on auditd since we need auditd to drain the
1492-
* queue; also, when we are checking for auditd, compare PIDs using
1493-
* task_tgid_vnr() since auditd_pid is set in audit_receive_msg() using
1494-
* a PID anchored in the caller's namespace */
1495-
if (!(audit_pid && audit_pid == task_tgid_vnr(current))) {
1491+
/* don't ever fail/sleep on these two conditions:
1492+
* 1. auditd generated record - since we need auditd to drain the
1493+
* queue; also, when we are checking for auditd, compare PIDs using
1494+
* task_tgid_vnr() since auditd_pid is set in audit_receive_msg()
1495+
* using a PID anchored in the caller's namespace
1496+
* 2. audit command message - record types 1000 through 1099 inclusive
1497+
* are command messages/records used to manage the kernel subsystem
1498+
* and the audit userspace, blocking on these messages could cause
1499+
* problems under load so don't do it (note: not all of these
1500+
* command types are valid as record types, but it is quicker to
1501+
* just check two ints than a series of ints in a if/switch stmt) */
1502+
if (!((audit_pid && audit_pid == task_tgid_vnr(current)) ||
1503+
(type >= 1000 && type <= 1099))) {
14961504
long sleep_time = audit_backlog_wait_time;
14971505

14981506
while (audit_backlog_limit &&

0 commit comments

Comments
 (0)