ctdb-recoverd: Avoid dereferencing NULL rec->nodemap
commit2dabb4c5cddc674c6a94ceaa42783cfef488cd4d
authorMartin Schwenke <martin@meltin.net>
Sun, 22 Mar 2020 02:46:46 +0000 (22 13:46 +1100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 30 Mar 2020 09:36:01 +0000 (30 09:36 +0000)
treed5571b15628ae4c62d03921cf19c7bcd06def9bf
parentb1b41b88a5ee6d5f06f9c1f722f5288f1af61203
ctdb-recoverd: Avoid dereferencing NULL rec->nodemap

Inside the nested event loop in ctdb_ctrl_getnodemap(), various
asynchronous handlers may dereference rec->nodemap, which will be
NULL.

One example is lost_reclock_handler(), which causes rec->nodemap to be
unconditionally dereferenced in list_of_nodes() via this call chain:

  list_of_nodes()
  list_of_active_nodes()
  set_recovery_mode()
  force_election()
  lost_reclock_handler()

Instead of attempting to trace all of the cases, just avoid leaving
rec->nodemap set to NULL.  Attempting to use an old value is generally
harmless, especially since it will be the same as the new value in
most cases.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14324

Reported-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Mar 24 01:22:45 UTC 2020 on sn-devel-184

(cherry picked from commit 716f52f68b248ae7cfd66479b3fc678c4a0d8b38)

Autobuild-User(v4-12-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-12-test): Mon Mar 30 09:36:01 UTC 2020 on sn-devel-184
ctdb/server/ctdb_recoverd.c