Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mod_http2: Fix possible beam bucket UAF in session destroy.
When the session pool is destroyed, so is the beam's pool so we don't want to run the beam cleanup twice. ASan is reporting something like this: ================================================================= ==81201==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000080ce8 at pc 0x7fdc78962cc9 bp 0x7fdc731ff4f0 sp 0x7fdc731ff4e8 READ of size 8 at 0x603000080ce8 thread T11 #0 0x7fdc78962cc8 in recv_buffer_cleanup /home/yle/src/ylavic/httpd/modules/http2/h2_bucket_beam.c:279 apache#1 0x7fdc78962fdc in beam_cleanup /home/yle/src/ylavic/httpd/modules/http2/h2_bucket_beam.c:306 apache#2 0x7fdc7896300c in beam_pool_cleanup /home/yle/src/ylavic/httpd/modules/http2/h2_bucket_beam.c:313 apache#3 0x7fdc7c5a8239 in run_cleanups memory/unix/apr_pools.c:2689 apache#4 0x7fdc7c5a50f9 in pool_clear_debug memory/unix/apr_pools.c:1867 apache#5 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#6 0x7fdc7c5a5179 in pool_clear_debug memory/unix/apr_pools.c:1880 apache#7 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#8 0x7fdc7c5a5179 in pool_clear_debug memory/unix/apr_pools.c:1880 apache#9 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#10 0x7fdc7c5a5179 in pool_clear_debug memory/unix/apr_pools.c:1880 apache#11 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#12 0x7fdc7c5a5827 in apr_pool_destroy_debug memory/unix/apr_pools.c:2014 apache#13 0x7fdc789aeaa5 in h2_session_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_session.c:1934 apache#14 0x7fdc7896a20e in h2_c1_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:188 apache#15 0x7fdc7896b538 in h2_c1_hook_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:308 apache#16 0x5596139aeb28 in ap_run_pre_close_connection /home/yle/src/ylavic/httpd/server/connection.c:45 apache#17 0x5596139af353 in ap_prep_lingering_close /home/yle/src/ylavic/httpd/server/connection.c:128 apache#18 0x5596139af3f2 in ap_start_lingering_close /home/yle/src/ylavic/httpd/server/connection.c:154 apache#19 0x7fdc7835bdf0 in process_lingering_close /home/yle/src/ylavic/httpd/server/mpm/event/event.c:1999 apache#20 0x7fdc78359ccb in process_socket /home/yle/src/ylavic/httpd/server/mpm/event/event.c:1540 apache#21 0x7fdc783608d7 in worker_thread /home/yle/src/ylavic/httpd/server/mpm/event/event.c:2756 apache#22 0x7fdc7c5d3e57 in dummy_worker threadproc/unix/thread.c:153 apache#23 0x7fdc7c441d7f in start_thread nptl/pthread_create.c:481 apache#24 0x7fdc7c337bde in clone (/lib/x86_64-linux-gnu/libc.so.6+0xfcbde) 0x603000080ce8 is located 8 bytes inside of 32-byte region [0x603000080ce0,0x603000080d00) freed by thread T11 here: #0 0x7fdc7c887f07 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122 apache#1 0x7fdc7c5a5420 in pool_clear_debug memory/unix/apr_pools.c:1906 apache#2 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#3 0x7fdc7c5a5179 in pool_clear_debug memory/unix/apr_pools.c:1880 apache#4 0x7fdc7c5a562e in pool_destroy_debug memory/unix/apr_pools.c:1965 apache#5 0x7fdc7c5a5827 in apr_pool_destroy_debug memory/unix/apr_pools.c:2014 apache#6 0x7fdc789aeaa5 in h2_session_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_session.c:1934 apache#7 0x7fdc7896a20e in h2_c1_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:188 apache#8 0x7fdc7896b538 in h2_c1_hook_pre_close /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:308 apache#9 0x5596139aeb28 in ap_run_pre_close_connection /home/yle/src/ylavic/httpd/server/connection.c:45 apache#10 0x5596139af353 in ap_prep_lingering_close /home/yle/src/ylavic/httpd/server/connection.c:128 apache#11 0x5596139af3f2 in ap_start_lingering_close /home/yle/src/ylavic/httpd/server/connection.c:154 apache#12 0x7fdc7835bdf0 in process_lingering_close /home/yle/src/ylavic/httpd/server/mpm/event/event.c:1999 apache#13 0x7fdc78359ccb in process_socket /home/yle/src/ylavic/httpd/server/mpm/event/event.c:1540 apache#14 0x7fdc783608d7 in worker_thread /home/yle/src/ylavic/httpd/server/mpm/event/event.c:2756 apache#15 0x7fdc7c5d3e57 in dummy_worker threadproc/unix/thread.c:153 apache#16 0x7fdc7c441d7f in start_thread nptl/pthread_create.c:481 previously allocated by thread T11 here: #0 0x7fdc7c8882b8 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144 apache#1 0x7fdc7c5a4d00 in pool_alloc memory/unix/apr_pools.c:1787 apache#2 0x7fdc7c5a507a in apr_palloc_debug memory/unix/apr_pools.c:1828 apache#3 0x7fdc7c4d8160 in apr_brigade_create buckets/apr_brigade.c:90 apache#4 0x7fdc7c4d82d8 in apr_brigade_split_ex buckets/apr_brigade.c:107 apache#5 0x7fdc78967f7c in h2_beam_receive /home/yle/src/ylavic/httpd/modules/http2/h2_bucket_beam.c:729 apache#6 0x7fdc789b65f0 in buffer_output_receive /home/yle/src/ylavic/httpd/modules/http2/h2_stream.c:847 apache#7 0x7fdc789bb655 in h2_stream_read_output /home/yle/src/ylavic/httpd/modules/http2/h2_stream.c:1372 apache#8 0x7fdc789aa155 in on_stream_output /home/yle/src/ylavic/httpd/modules/http2/h2_session.c:1313 apache#9 0x7fdc789956ba in mplx_pollset_poll /home/yle/src/ylavic/httpd/modules/http2/h2_mplx.c:1299 apache#10 0x7fdc7898deb8 in h2_mplx_c1_poll /home/yle/src/ylavic/httpd/modules/http2/h2_mplx.c:532 apache#11 0x7fdc789ae04b in h2_session_process /home/yle/src/ylavic/httpd/modules/http2/h2_session.c:1863 apache#12 0x7fdc78969b0f in h2_c1_run /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:138 apache#13 0x7fdc7896b302 in h2_c1_hook_process_connection /home/yle/src/ylavic/httpd/modules/http2/h2_c1.c:286 apache#14 0x5596139ae4b6 in ap_run_process_connection /home/yle/src/ylavic/httpd/server/connection.c:43 apache#15 0x7fdc78358d67 in process_socket /home/yle/src/ylavic/httpd/server/mpm/event/event.c:1353 apache#16 0x7fdc783608d7 in worker_thread /home/yle/src/ylavic/httpd/server/mpm/event/event.c:2756 apache#17 0x7fdc7c5d3e57 in dummy_worker threadproc/unix/thread.c:153 apache#18 0x7fdc7c441d7f in start_thread nptl/pthread_create.c:481 Thread T11 created by T2 here: #0 0x7fdc7c7baa22 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208 apache#1 0x7fdc7c5d4534 in apr_thread_create threadproc/unix/thread.c:228 apache#2 0x7fdc7836273d in start_threads /home/yle/src/ylavic/httpd/server/mpm/event/event.c:3035 apache#3 0x7fdc7c5d3e57 in dummy_worker threadproc/unix/thread.c:153 apache#4 0x7fdc7c441d7f in start_thread nptl/pthread_create.c:481 Thread T2 created by T0 here: #0 0x7fdc7c7baa22 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208 apache#1 0x7fdc7c5d4534 in apr_thread_create threadproc/unix/thread.c:228 apache#2 0x7fdc78363d9f in child_main /home/yle/src/ylavic/httpd/server/mpm/event/event.c:3262 apache#3 0x7fdc7836483b in make_child /home/yle/src/ylavic/httpd/server/mpm/event/event.c:3421 apache#4 0x7fdc78364b89 in startup_children /home/yle/src/ylavic/httpd/server/mpm/event/event.c:3444 apache#5 0x7fdc78368abc in event_run /home/yle/src/ylavic/httpd/server/mpm/event/event.c:3932 apache#6 0x5596139b6d18 in ap_run_mpm /home/yle/src/ylavic/httpd/server/mpm_common.c:101 apache#7 0x55961399098b in main /home/yle/src/ylavic/httpd/server/main.c:880 apache#8 0x7fdc7c2627ec in __libc_start_main ../csu/libc-start.c:332 SUMMARY: AddressSanitizer: heap-use-after-free /home/yle/src/ylavic/httpd/modules/http2/h2_bucket_beam.c:279 in recv_buffer_cleanup Shadow bytes around the buggy address: 0x0c0680008140: fa fa 00 00 00 00 fa fa fd fd fd fa fa fa fd fd 0x0c0680008150: fd fd fa fa fd fd fd fd fa fa fd fd fd fd fa fa 0x0c0680008160: fd fd fd fd fa fa fd fd fd fd fa fa fd fd fd fd 0x0c0680008170: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd 0x0c0680008180: fd fd fa fa fd fd fd fd fa fa fd fd fd fa fa fa =>0x0c0680008190: fd fd fd fa fa fa fd fd fd fa fa fa fd[fd]fd fd 0x0c06800081a0: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd 0x0c06800081b0: fd fd fa fa fd fd fd fd fa fa fd fd fd fd fa fa 0x0c06800081c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c06800081d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c06800081e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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 ==81201==ABORTING
- Loading branch information