]> git.kaiwu.me - nginx.git/commit
Fixed segfault when switching off master process during upgrade.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 23 Nov 2022 20:48:53 +0000 (23:48 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 23 Nov 2022 20:48:53 +0000 (23:48 +0300)
commitd52e5684437aedd6bb74d6b2b602b7306f4212ba
tree36652257f10b3d84604b33bd30b49c4d6064991f
parent593bb543873ac57efade09dbcc2f93ab6b4d5ab0
Fixed segfault when switching off master process during upgrade.

Binary upgrades are not supported without master process, but it is,
however, possible, that nginx running with master process is asked
to upgrade binary, and the configuration file as available on disk
at this time includes "master_process off;".

If this happens, listening sockets inherited from the previous binary
will have ls[i].previous set.  But the old cycle on initial process
startup, including startup after binary upgrade, is destroyed by
ngx_init_cycle() once configuration parsing is complete.  As a result,
an attempt to dereference ls[i].previous in ngx_event_process_init()
accesses already freed memory.

Fix is to avoid looking into ls[i].previous if the old cycle is already
freed.

With this change it is also no longer needed to clear ls[i].previous in
worker processes, so the relevant code was removed.
src/event/ngx_event.c
src/os/unix/ngx_process_cycle.c