]> git.tuebingen.mpg.de Git - paraslash.git/commit
server: Avoid deadlock in daemon_log().
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 9 Nov 2022 19:20:26 +0000 (20:20 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 25 Nov 2022 12:19:51 +0000 (13:19 +0100)
commit10596c5a763716368579b6313953ae0861b03ad4
treecf97f8a31d10fb0a798fbfb699eec97c7b3b620a
parente2ad488f4d30b6d9617702b8ce868ed7c55a4247
server: Avoid deadlock in daemon_log().

Currently both the generic signal handler in signal.c and the signal
handler for the stat command handler in command.c call daemon_log()
via PARA_EMERG_LOG(). This is problematic because daemon_log()
takes the log mutex and the signal might arrive while daemon_log()
is executing. If this race condition is hit, the process deadlocks
because daemon_log() tries to acquire a mutex which it already holds.

All three types of server processes (main, afs and command handler)
are susceptible to this bug, but regardless of which process happens
to hit the race window, the server process hangs waiting on the mutex,
and no longer accepts connections.

Fix this by removing the problematic log call in the generic case and
by printing it out of interrupt context in the command handler case.

This bug was introduced together with the log mutex five years ago.

Fixes: ced0c17d1a3ee0336dc7b35e69faff131dabecac
command.c
signal.c