Skip to content

Commit 6b55fc6

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
audit, sched/wait: Fixup kauditd_thread() wait loop
The kauditd_thread wait loop is a bit iffy; it has a number of problems: - calls try_to_freeze() before schedule(); you typically want the thread to re-evaluate the sleep condition when unfreezing, also freeze_task() issues a wakeup. - it unconditionally does the {add,remove}_wait_queue(), even when the sleep condition is false. Use wait_event_freezable() that does the right thing. Reported-by: Mike Galbraith <umgwanakikbuti@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Eric Paris <eparis@redhat.com> Cc: oleg@redhat.com Cc: Eric Paris <eparis@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20141002102251.GA6324@worktop.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 5d4d565 commit 6b55fc6

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

kernel/audit.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ static int kauditd_thread(void *dummy)
499499
set_freezable();
500500
while (!kthread_should_stop()) {
501501
struct sk_buff *skb;
502-
DECLARE_WAITQUEUE(wait, current);
503502

504503
flush_hold_queue();
505504

@@ -514,16 +513,8 @@ static int kauditd_thread(void *dummy)
514513
audit_printk_skb(skb);
515514
continue;
516515
}
517-
set_current_state(TASK_INTERRUPTIBLE);
518-
add_wait_queue(&kauditd_wait, &wait);
519516

520-
if (!skb_queue_len(&audit_skb_queue)) {
521-
try_to_freeze();
522-
schedule();
523-
}
524-
525-
__set_current_state(TASK_RUNNING);
526-
remove_wait_queue(&kauditd_wait, &wait);
517+
wait_event_freezable(kauditd_wait, skb_queue_len(&audit_skb_queue));
527518
}
528519
return 0;
529520
}

0 commit comments

Comments
 (0)