linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] audit: refactor and fix for potential deadlock
@ 2023-05-08  7:58 Eiichi Tsukata
  2023-05-08  7:58 ` [PATCH 1/4] audit: refactor queue full checks Eiichi Tsukata
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Eiichi Tsukata @ 2023-05-08  7:58 UTC (permalink / raw)
  To: paul, eparis, linux-kernel, audit; +Cc: Eiichi Tsukata

Commit 7ffb8e317bae ("audit: we don't need to
__set_current_state(TASK_RUNNING)") accidentally moved queue full check
before add_wait_queue_exclusive() which introduced the following race:

    CPU1                           CPU2
  ========                       ========
  (in audit_log_start())         (in kauditd_thread())

  queue is full
                                 wake_up(&audit_backlog_wait)
                                 wait_event_freezable()
  add_wait_queue_exclusive()
  ...
  schedule_timeout()

Once this happens, both audit_log_start() and kauditd_thread() can cause
deadlock for up to backlog_wait_time waiting for each other. To prevent
the race, this patch adds queue full check after
prepare_to_wait_exclusive().

This patchset consists of the following parts:

Patch 1-3: Refactorings and a small fix preferable for deadlock fix
Patch 4: Actual deadlock fix

Eiichi Tsukata (4):
  audit: refactor queue full checks
  audit: account backlog waiting time in audit_receive()
  audit: convert DECLARE_WAITQUEUE to DEFINE_WAIT
  audit: check if queue is full after prepare_to_wait_exclusive()

 kernel/audit.c | 71 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 43 insertions(+), 28 deletions(-)

-- 
2.40.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-05-17 16:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08  7:58 [PATCH 0/4] audit: refactor and fix for potential deadlock Eiichi Tsukata
2023-05-08  7:58 ` [PATCH 1/4] audit: refactor queue full checks Eiichi Tsukata
2023-05-10  6:54   ` Rinat Gadelshin
2023-05-10  7:17     ` Eiichi Tsukata
2023-05-10  7:28       ` Rinat Gadelshin
2023-05-08  7:58 ` [PATCH 2/4] audit: account backlog waiting time in audit_receive() Eiichi Tsukata
2023-05-08  7:58 ` [PATCH 3/4] audit: convert DECLARE_WAITQUEUE to DEFINE_WAIT Eiichi Tsukata
2023-05-08  7:58 ` [PATCH 4/4] audit: check if queue is full after prepare_to_wait_exclusive() Eiichi Tsukata
2023-05-08 17:13   ` kernel test robot
2023-05-09  1:44     ` Eiichi Tsukata
2023-05-08 14:07 ` [PATCH 0/4] audit: refactor and fix for potential deadlock Paul Moore
2023-05-09  1:34   ` Eiichi Tsukata
2023-05-10  8:09     ` Eiichi Tsukata
2023-05-17 16:15       ` Paul Moore
2023-05-17 16:03     ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).