Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG/MEDIUM: quic: Possible crash during retransmissions and heavy load
This bug could be reproduced with -dMfail and dectected by libasan as follows: $ ASAN_OPTIONS=disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=f quic-freeze.cfg -dMfail -dMno-cache -dM0x55 ================================================================= ==82989==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffc 0x560790cc4749 bp 0x7fff8e0e8e30 sp 0x7fff8e0e8e28 WRITE of size 8 at 0x7fff8e0ea338 thread T0 #0 0x560790cc4748 in qc_frm_free src/quic_frame.c:1222 #1 0x560790cc5260 in qc_release_frm src/quic_frame.c:1261 #2 0x560790d1de99 in qc_treat_acked_tx_frm src/quic_rx.c:312 haproxy#3 0x560790d1e708 in qc_ackrng_pkts src/quic_rx.c:370 haproxy#4 0x560790d22a1d in qc_parse_ack_frm src/quic_rx.c:694 haproxy#5 0x560790d25daa in qc_parse_pkt_frms src/quic_rx.c:988 haproxy#6 0x560790d2a509 in qc_treat_rx_pkts src/quic_rx.c:1373 haproxy#7 0x560790c72d45 in quic_conn_io_cb src/quic_conn.c:906 haproxy#8 0x560791207847 in run_tasks_from_lists src/task.c:596 haproxy#9 0x5607912095f0 in process_runnable_tasks src/task.c:876 haproxy#10 0x560791135564 in run_poll_loop src/haproxy.c:2966 haproxy#11 0x5607911363af in run_thread_poll_loop src/haproxy.c:3165 haproxy#12 0x56079113938c in main src/haproxy.c:3862 haproxy#13 0x7f92606edd09 in __libc_start_main ../csu/libc-start.c:308 haproxy#14 0x560790bcd529 in _start (/home/flecaille/src/haproxy/haproxy+0x Address 0x7fff8e0ea338 is located in stack of thread T0 at offset 1032 i #0 0x560790d29b52 in qc_treat_rx_pkts src/quic_rx.c:1341 This frame has 2 object(s): [32, 48) 'ar' (line 1380) [64, 1088) '_msg' (line 1368) <== Memory access at offset 1032 is inable HINT: this may be a false positive if your program uses some custom stacnism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-use-after-scope src/quic_frame.c:1222 i Shadow bytes around the buggy address: 0x100071c15410: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x100071c15420: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x100071c15430: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x100071c15440: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x100071c15450: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 =>0x100071c15460: f8 f8 f8 f8 f8 f8 f8[f8]f8 f8 f8 f8 f8 f8 f3 f3 0x100071c15470: f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 00 00 0x100071c15480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100071c15490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100071c154a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100071c154b0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f3 f3 f3 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==82989==ABORTING AddressSanitizer:DEADLYSIGNAL AddressSanitizer:DEADLYSIGNAL AddressSanitizer:DEADLYSIGNAL AddressSanitizer:DEADLYSIGNAL AddressSanitizer:DEADLYSIGNAL AddressSanitizer:DEADLYSIGNAL Aborted (core dumped) Note that a coredump could not always be produced with all compilers. This was always the case with clang 11. When allocating frames to be retransmitted from qc_dgrams_retransmit(), if they could not be sent for any reason, they could remain attached to a local list to qc_dgrams_retransmit() and trigger a crash with libasan when releasing the original frames they were duplicated from. To fix this, always release the frames which could not be sent during retransmissions calling qc_free_frm_list() where needed. Must be backported as far as 2.6.
- Loading branch information