annotate auto/os/win32 @ 6359:dac6eda40475 stable-1.8

Resolver: fixed use-after-free memory accesses with CNAME. When several requests were waiting for a response, then after getting a CNAME response only the last request's context had the name updated. Contexts of other requests had the wrong name. This name was used by ngx_resolve_name_done() to find the node to remove the request context from. When the name was wrong, the request could not be properly cancelled, its context was freed but stayed linked to the node's waiting list. This happened e.g. when the first request was aborted or timed out before the resolving completed. When it completed, this triggered a use-after-free memory access by calling ctx->handler of already freed request context. The bug manifests itself by "could not cancel <name> resolving" alerts in error_log. When a request was responded with a CNAME, the request context kept the pointer to the original node's rn->u.cname. If the original node expired before the resolving timed out or completed with an error, this would trigger a use-after-free memory access via ctx->name in ctx->handler(). The fix is to keep ctx->name unmodified. The name from context is no longer used by ngx_resolve_name_done(). Instead, we now keep the pointer to resolver node to which this request is linked. Keeping the original name intact also improves logging.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 26 Jan 2016 16:46:59 +0300
parents 3d2d3e1cf427
children 4dc8e7b62216
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 # Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 2814
diff changeset
3 # Copyright (C) Nginx, Inc.
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
6 have=NGX_WIN32 . auto/have_headers
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 CORE_INCS="$WIN32_INCS"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 CORE_DEPS="$WIN32_DEPS"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 OS_CONFIG="$WIN32_CONFIG"
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
12 NGX_ICONS="$NGX_WIN32_ICONS"
2813
c00763aa5e1b divide select module into two modules: Unix and Win32 ones
Igor Sysoev <igor@sysoev.ru>
parents: 2731
diff changeset
13 SELECT_SRCS=$WIN32_SELECT_SRCS
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
5360
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
15 case "$NGX_CC_NAME" in
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
16
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
17 gcc)
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
18 CORE_LIBS="$CORE_LIBS -ladvapi32 -lws2_32"
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
19 ;;
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
20
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
21 *)
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
22 CORE_LIBS="$CORE_LIBS advapi32.lib ws2_32.lib"
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
23 ;;
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
24
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
25 esac
3d2d3e1cf427 Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4412
diff changeset
26
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 EVENT_FOUND=YES
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 if [ $EVENT_SELECT = NO ]; then
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 fi
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34
2814
219aa0b0fd58 IPv6 for Win32
Igor Sysoev <igor@sysoev.ru>
parents: 2813
diff changeset
35 if [ $NGX_IPV6 = YES ]; then
219aa0b0fd58 IPv6 for Win32
Igor Sysoev <igor@sysoev.ru>
parents: 2813
diff changeset
36 have=NGX_HAVE_INET6 . auto/have
219aa0b0fd58 IPv6 for Win32
Igor Sysoev <igor@sysoev.ru>
parents: 2813
diff changeset
37 fi
219aa0b0fd58 IPv6 for Win32
Igor Sysoev <igor@sysoev.ru>
parents: 2813
diff changeset
38
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
39 have=NGX_HAVE_AIO . auto/have
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
40 have=NGX_HAVE_IOCP . auto/have