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

GitHub workflow: Add Alpine Linux job #2115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Antelox
Copy link
Contributor

@Antelox Antelox commented Feb 19, 2025

@Antelox Antelox force-pushed the alpine_workflow branch 2 times, most recently from de37fa9 to a2a6852 Compare February 19, 2025 14:45
@Antelox Antelox marked this pull request as ready for review March 4, 2025 16:35
@wtdcode
Copy link
Member

wtdcode commented Mar 6, 2025

@PhilippTakacs

This workflow reveals a UAF bug. Reproduction it with:

mkdir build
cd build 
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fsanitize=address
make -j
./test_mem test_snapshot

This gives:

Test test_snapshot...                           =================================================================
==2000659==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e0000005dc at pc 0x7fdd650b3675 bp 0x7ffebe9070e0 sp 0x7ffebe9070d0
READ of size 4 at 0x60e0000005dc thread T0
    #0 0x7fdd650b3674 in address_space_dispatch_clear_x86_64 /home/mio/opensource/unicorn/qemu/exec.c:1466
    #1 0x7fdd650c3c92 in flatview_copy_x86_64 /home/mio/opensource/unicorn/qemu/softmmu/memory.c:945
    #2 0x7fdd6507e4f6 in uc_context_restore /home/mio/opensource/unicorn/uc.c:2450
    #3 0x5651d49fbdfa in test_snapshot /home/mio/opensource/unicorn/tests/unit/test_mem.c:305
    #4 0x5651d49f3da8 in acutest_do_run_ /home/mio/opensource/unicorn/tests/unit/acutest.h:1027
    #5 0x5651d49f4501 in acutest_run_ /home/mio/opensource/unicorn/tests/unit/acutest.h:1234
    #6 0x5651d49f6b96 in main /home/mio/opensource/unicorn/tests/unit/acutest.h:1832
    #7 0x7fdd64629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #8 0x7fdd64629e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #9 0x5651d49f1ac4 in _start (/home/mio/opensource/unicorn/build/test_mem+0x7ac4)

0x60e0000005dc is located 92 bytes inside of 160-byte region [0x60e000000580,0x60e000000620)
freed by thread T0 here:
    #0 0x7fdd67eb4537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127
    #1 0x7fdd6508fcca in g_free /home/mio/opensource/unicorn/glib_compat/gmem.c:256
    #2 0x7fdd650be1fc in memory_region_filter_subregions_x86_64 /home/mio/opensource/unicorn/qemu/softmmu/memory.c:222
    #3 0x7fdd650817c5 in uc_restore_latest_snapshot /home/mio/opensource/unicorn/uc.c:2881
    #4 0x7fdd6507e353 in uc_context_restore /home/mio/opensource/unicorn/uc.c:2442
    #5 0x5651d49fbdfa in test_snapshot /home/mio/opensource/unicorn/tests/unit/test_mem.c:305
    #6 0x5651d49f3da8 in acutest_do_run_ /home/mio/opensource/unicorn/tests/unit/acutest.h:1027
    #7 0x5651d49f4501 in acutest_run_ /home/mio/opensource/unicorn/tests/unit/acutest.h:1234
    #8 0x5651d49f6b96 in main /home/mio/opensource/unicorn/tests/unit/acutest.h:1832
    #9 0x7fdd64629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

previously allocated by thread T0 here:
    #0 0x7fdd67eb4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fdd6508fb18 in g_malloc /home/mio/opensource/unicorn/glib_compat/gmem.c:93
    #2 0x7fdd6508fb64 in g_malloc_n /home/mio/opensource/unicorn/glib_compat/gmem.c:122
    #3 0x7fdd650bd4f9 in memory_cow_x86_64 /home/mio/opensource/unicorn/qemu/softmmu/memory.c:100
    #4 0x7fdd65150a49 in store_helper /home/mio/opensource/unicorn/qemu/accel/tcg/cputlb.c:2228
    #5 0x7fdd651514d0 in helper_le_stl_mmu_x86_64 /home/mio/opensource/unicorn/qemu/accel/tcg/cputlb.c:2390
    #6 0x7fdd212003b5  (<unknown module>)

SUMMARY: AddressSanitizer: heap-use-after-free /home/mio/opensource/unicorn/qemu/exec.c:1466 in address_space_dispatch_clear_x86_64
Shadow bytes around the buggy address:
  0x0c1c7fff8060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c1c7fff8070: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c1c7fff8080: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
  0x0c1c7fff8090: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c1c7fff80a0: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
=>0x0c1c7fff80b0: fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd fd fd
  0x0c1c7fff80c0: fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c1c7fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c1c7fff80e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c1c7fff80f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c1c7fff8100: 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
==2000659==ABORTING

The underlying memory regions are accessed after free. Would you like to draft a fix?

@PhilippTakacs
Copy link
Contributor

The underlying memory regions are accessed after free. Would you like to draft a fix?

Yes, I'm working on it.

@wtdcode
Copy link
Member

wtdcode commented Mar 6, 2025

The underlying memory regions are accessed after free. Would you like to draft a fix?

Yes, I'm working on it.

Thanks!

By the way, please draft a standalone PR to master branch directly as we are releasing 2.1.3 shortly.

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.

3 participants