s3:messages: make the loop in msg_dgm_ref_recv() more robust against stale pointers
authorStefan Metzmacher <metze@samba.org>
Mon, 9 Jul 2018 10:33:34 +0000 (12:33 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 10 Jul 2018 18:31:13 +0000 (20:31 +0200)
commit1a9d6ce58939678f88b3081fb91c3309ff3cddb7
treec981e6f6e581d80c65aaa3f2a6c4245ac6b1bc62
parent0503bbab958754bc8ba32da8578602927ebf25c0
s3:messages: make the loop in msg_dgm_ref_recv() more robust against stale pointers

The interaction between msg_dgm_ref_recv() and msg_dgm_ref_destructor()
doesn't allow two references from messaging_dgm_ref() to be free'd
during the loop in msg_dgm_ref_recv().

In addition to the global 'refs' list, we also need to
have a global 'next_ref' pointer, which can be adjusted in
msg_dgm_ref_destructor().

As AD DC we hit this when using irpc in auth_winbind,
which uses imessaging_client_init().
In addition to the main messaging_dgm_ref() in smbd,
source3/auth/auth_samba4.c: prepare_gensec() and
make_auth4_context_s4() also generate a temporary
imessaging_context for auth_context->msg_ctx from within
auth_generic_prepare().

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13514

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/imessaging [deleted file]
source3/lib/messages_dgm_ref.c