Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed segfault in ngx_http_find_virtual_server() within xquic module #1813

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

morf
Copy link
Contributor

@morf morf commented Jul 10, 2023

A segfault was corrected when calling ngx_http_find_virtual_server in the xquic module. The issue originated from c->data being taken as ngx_http_connection_t while regular expressions were in use. However, for http3 connections, c->data is a pointer to ngx_http_xquic_connection_t

@drawing
Copy link
Collaborator

drawing commented Jul 20, 2023

Can you show the configuration when segfault occurs?

@morf
Copy link
Contributor Author

morf commented Jul 20, 2023

nginx.conf (with two servers for run regexp in ngx_http_find_virtual_server):

worker_processes 1;
daemon off;
master_process off;

error_log /dev/stdout debug;

http {

    xquic_ssl_certificate /path-to/nginx-selfsigned.crt;
    xquic_ssl_certificate_key /path-to/nginx-selfsigned.key;

    xquic_log_file /dev/stdout;
    xquic_log_level debug;

    server {
        listen 8081 reuseport xquic;
        server_name "~^test\.com$";

        location / {
            return 200 "ok\n";
        }
    }

    server {
        listen 8081 xquic;
        server_name "~^test2\.com$";

        location / {
            return 200 "ok\n";
        }
    }
}

events { }

run:

gdb --arg ./objs/nginx -p /tmp/ -c /path-to/nginx.conf

command:

curl -k -v --resolve test.com:8081:127.0.0.1 --http3-only 'https://test.com:8081'

segfault:

2023/07/20 21:30:13 [warn] 8095#0: |xquic|lib[debug] |scid:a96fcd03d7d27c468579261d|xqc_h3_stream_process_bidi|xqc_h3_stream_process_bidi|10|1||
2023/07/20 21:30:13 [debug] 8095#0: |xquic|xqc_http_v3_request_create_notify|
2023/07/20 21:30:13 [debug] 8095#0: |xquic|xqc_http_v3_request_create_notify in connection|0000AAAB00974120|

Program received signal SIGSEGV, Segmentation fault.
ngx_http_v3_create_stream (stream_id=0, h3c=0xaaab00974120) at /path/tengine/modules/ngx_http_xquic_module/ngx_http_v3_stream.c:112
112         ngx_memzero(rev, sizeof(ngx_event_t));
(gdb)

problem code:

hc = c->data;

A segfault was corrected when calling ngx_http_find_virtual_server in the xquic module. The issue originated from c->data being taken as ngx_http_connection_t while regular expressions were in use. However, for http3 connections, c->data is a pointer to ngx_http_xquic_connection_t
@drawing drawing merged commit 636722c into alibaba:master Aug 4, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants