bind9/bin/named
Diego Fronza 942b83d392 Fix deadlock between rndc addzone/delzone/modzone
It follows a description of the steps that were leading to the deadlock:

1. `do_addzone` calls `isc_task_beginexclusive`.

2. `isc_task_beginexclusive` waits for (N_WORKERS - 1) halted tasks,
   this blocks waiting for those (no. workers -1) workers to halt.
...
isc_task_beginexclusive(isc_task_t *task0) {
    ...
	while (manager->halted + 1 < manager->workers) {
		wake_all_queues(manager);
		WAIT(&manager->halt_cond, &manager->halt_lock);
	}
```

3. It is possible that in `task.c / dispatch()` a worker is running a
   task event, if that event blocks it will not allow this worker to
   halt.

4. `do_addzone` acquires `LOCK(&view->new_zone_lock);`,

5. `rmzone` event is called from some worker's `dispatch()`, `rmzone`
   blocks waiting for the same lock.

6. `do_addzone` calls `isc_task_beginexclusive`.

7. Deadlock triggered, since:
	- `rmzone` is wating for the lock.
	- `isc_task_beginexclusive` is waiting for (no. workers - 1) to
	   be halted
	- since `rmzone` event is blocked it won't allow the worker to halt.

To fix this, we updated do_addzone code to call isc_task_beginexclusive
before the lock is acquired, we postpone locking to the nearest required
place, same for isc_task_beginexclusive.

The same could happen with rndc modzone, so that was addressed as well.
2021-04-26 11:35:18 -03:00
..
include Pass an afg_aclconfctx_t structure to cfg_acl_fromconfig 2021-01-28 13:43:47 +11:00
unix update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
win32 Add libssl libraries to Windows build 2020-12-09 10:46:16 +01:00
.gitignore [master] add libns and remove liblwres 2017-09-08 13:47:34 -07:00
bind9.xsl update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
bind9.xsl.h Regenerate couple of generated files 2020-09-30 22:14:39 +02:00
builtin.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
config.c Change default stale-answer-client-timeout to off 2021-04-07 14:46:55 +02:00
control.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
controlconf.c Lock access to control->symtab to prevent data race 2020-09-17 19:31:41 +10:00
convertxsl.pl update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
fuzz.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
geoip.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
log.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
logconf.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
main.c Update named's usage description 2021-04-13 11:35:13 +10:00
Makefile.in Re-order include directories 2021-02-16 12:08:21 +11:00
named.conf.rst Add purge-keys config option 2021-02-23 09:18:55 +01:00
named.rst Update documentation on -E option 2021-01-19 09:06:01 +01:00
server.c Fix deadlock between rndc addzone/delzone/modzone 2021-04-26 11:35:18 -03:00
statschannel.c Stop xmlFreeTextWriter being called twice 2021-01-28 21:42:44 +00:00
tkeyconf.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
tsigconf.c update all copyright headers to eliminate the typo 2020-09-14 16:50:58 -07:00
zoneconf.c Pass an afg_aclconfctx_t structure to cfg_acl_fromconfig 2021-01-28 13:43:47 +11:00