Skip to content

Commit

Permalink
audit: audit_log_start running on auditd should not stop
Browse files Browse the repository at this point in the history
The backlog cannot be consumed when audit_log_start is running on auditd
even if audit_log_start calls wait_for_auditd to consume it.
The situation is the deadlock because only auditd can consume the backlog.
If the other process needs to send the backlog, it can be also stopped
by the deadlock.

So, audit_log_start running on auditd should not stop.

You can see the deadlock with the following reproducer:
 # auditctl -a exit,always -S all
 # reboot

Signed-off-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
Reviewed-by: gaofeng@cn.fujitsu.com
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
  • Loading branch information
Toshiyuki Okajima authored and eparis committed Jan 14, 2014
1 parent 1b7b533 commit 6dd80ab
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
struct audit_buffer *ab = NULL;
struct timespec t;
unsigned int uninitialized_var(serial);
int reserve;
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
unsigned long timeout_start = jiffies;

if (audit_initialized != AUDIT_INITIALIZED)
Expand All @@ -1328,11 +1329,12 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
if (unlikely(audit_filter_type(type)))
return NULL;

if (gfp_mask & __GFP_WAIT)
reserve = 0;
else
reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
if (gfp_mask & __GFP_WAIT) {
if (audit_pid && audit_pid == current->pid)
gfp_mask &= ~__GFP_WAIT;
else
reserve = 0;
}

while (audit_backlog_limit
&& skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) {
Expand Down

0 comments on commit 6dd80ab

Please sign in to comment.