ctdb: Fix a crash in run_proc_signal_handler()
authorVolker Lendecke <vl@samba.org>
Tue, 18 May 2021 06:32:45 +0000 (08:32 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 25 May 2021 08:55:59 +0000 (08:55 +0000)
commitc67dbd55aadfffb8ee7623aacbda13aa5c676418
tree7b72c6575400ad68089698fa7afa69188a9d0742
parent037f4b8fb9a3f3ee373441ea31ab0755053df3c2
ctdb: Fix a crash in run_proc_signal_handler()

If a script times out the caller can talloc_free() the script_list
output of run_event_recv, which talloc_free's proc->output from
run_proc.c as well. If the script generates further output after the
timeout and then exits after a while, the SIGCHLD handler in the
eventd tries to read into proc->output, which was already free'ed.

Fix this by not doing just a talloc_steal but a talloc_move. This way
proc_read_handler() called from run_proc_signal_handler() does not try
to realloc the stale reference to proc->output but gets a NULL
reference.

I don't really know how to do a knownfail in ctdb, so this commit
actually activates catching the signal by waiting long enough for
22.bar to exit and generate the SIGCHLD.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit adef87a621b17baf746d12f991c60a8a3ffcfcd3)

Autobuild-User(v4-13-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-13-test): Tue May 25 08:55:59 UTC 2021 on sn-devel-184
ctdb/common/run_proc.c
ctdb/tests/src/run_event_test.c