Welcome! Log In Create A New Profile

Advanced

[PATCH] Fixed segfault when switching off master process during upgrade

Maxim Dounin
October 29, 2022 10:44PM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1667097733 -10800
# Sun Oct 30 05:42:13 2022 +0300
# Node ID ef9c94be7fe4685f0eeee41f76b964ea252f519f
# Parent b73d95226c84b93e51f23f7b35782d98d3b516b9
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.

diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -813,7 +813,9 @@ ngx_event_process_init(ngx_cycle_t *cycl
rev->deferred_accept = ls[i].deferred_accept;
#endif

- if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
+ if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)
+ && cycle->old_cycle)
+ {
if (ls[i].previous) {

/*

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] Fixed segfault when switching off master process during upgrade

Maxim Dounin 460 October 29, 2022 10:44PM

Re: [PATCH] Fixed segfault when switching off master process during upgrade

Maxim Dounin 16 November 18, 2022 08:58AM

Re: [PATCH] Fixed segfault when switching off master process during upgrade

Roman Arutyunyan 12 November 23, 2022 08:58AM

Re: [PATCH] Fixed segfault when switching off master process during upgrade

Maxim Dounin 18 November 23, 2022 03:54PM

Re: [PATCH] Fixed segfault when switching off master process during upgrade

Roman Arutyunyan 20 November 24, 2022 04:12AM

Re: [PATCH] Fixed segfault when switching off master process during upgrade

Maxim Dounin 33 November 24, 2022 01:28PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 86
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready