fix(config): serialize load_primary_config against concurrent invocations (bug-1476)
myconf->lock (mylock_init/fini wiring) had landed but load_primary_config() itself was left in its RED-phase reproduction state (unguarded, decoding directly into the shared myconf->cluster_config field), so the fix's own regression test failed on resume: thread B raced through while thread A was parked mid-call. Wraps the whole free-decode-publish sequence in myconf->lock (acquired first, released on every return path) and decodes into a local cluster_config_t* first, publishing into myconf->cluster_config only after full decode and validation succeed -- closing the UAF/double-free window a live 3-node ASan soak caught (two concurrent handle_repl_config_push deliveries for the same standby racing two load_primary_config calls). Verified 4/4 clean full-suite runs (1036 tests, 0 failures) including the specific race test.
This commit is contained in:
parent
ce8df99037
commit
b08e392eeb
8 changed files with 704 additions and 31 deletions
|
|
@ -400,6 +400,14 @@ int main(int argc, char* argv[])
|
|||
myconf.xstrings_delta = arguments.xstrings_delta;
|
||||
memset(&myconf.peers_cfg, 0, sizeof(myconf.peers_cfg));
|
||||
|
||||
/* bug-1476: myconf.lock serializes load_primary_config() against
|
||||
* concurrent invocations for this myconf_t — must be initialized before
|
||||
* cluster_run/myapp_run can ever call it. */
|
||||
if (mylock_init(&myconf.lock) != 0) {
|
||||
ERROR("Failed to initialize myconf lock");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (arguments.peers_str) {
|
||||
if (xce_parse_peers(arguments.peers_str, &myconf.peers_cfg) != 0) {
|
||||
fprintf(stderr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue