aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorToshiyuki Okajima <toshi.okajima@jp.fujitsu.com>2013-12-05 02:15:23 -0500
committerEric Paris <eparis@redhat.com>2014-01-13 22:32:22 -0500
commit6dd80aba90639d1765396aa5e5f55e34dc3356e5 (patch)
tree5198fe1e1c3fe0bd4a1235414a93e108ce451c74 /kernel
parent1b7b533f65db9b31f76972b2899ec7ec6433ae77 (diff)
audit: audit_log_start running on auditd should not stop
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/audit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index c05b6027e874..9c4ec29a707b 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1319,7 +1319,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
1319 struct audit_buffer *ab = NULL; 1319 struct audit_buffer *ab = NULL;
1320 struct timespec t; 1320 struct timespec t;
1321 unsigned int uninitialized_var(serial); 1321 unsigned int uninitialized_var(serial);
1322 int reserve; 1322 int reserve = 5; /* Allow atomic callers to go up to five
1323 entries over the normal backlog limit */
1323 unsigned long timeout_start = jiffies; 1324 unsigned long timeout_start = jiffies;
1324 1325
1325 if (audit_initialized != AUDIT_INITIALIZED) 1326 if (audit_initialized != AUDIT_INITIALIZED)
@@ -1328,11 +1329,12 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
1328 if (unlikely(audit_filter_type(type))) 1329 if (unlikely(audit_filter_type(type)))
1329 return NULL; 1330 return NULL;
1330 1331
1331 if (gfp_mask & __GFP_WAIT) 1332 if (gfp_mask & __GFP_WAIT) {
1332 reserve = 0; 1333 if (audit_pid && audit_pid == current->pid)
1333 else 1334 gfp_mask &= ~__GFP_WAIT;
1334 reserve = 5; /* Allow atomic callers to go up to five 1335 else
1335 entries over the normal backlog limit */ 1336 reserve = 0;
1337 }
1336 1338
1337 while (audit_backlog_limit 1339 while (audit_backlog_limit
1338 && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) { 1340 && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) {