Skip to content

ASAN: stack-buffer-overflow in OSBA_ISM3_PlanarHOA2 JBM decoding to

Basic info

Bug description

Clang ASAN sanitizer test in pipeline found an error:

==2631128==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffc67526a40 at pc 0x00000096d75f bp 0x7ffc675135f0 sp 0x7ffc675135e8
READ of size 4 at 0x7ffc67526a40 thread T0
    #0 0x96d75e in ivas_ism_render_sf /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/ivas_ism_renderer.c:262:67
    #1 0x5fb178 in ivas_osba_render_sf /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/ivas_osba_dec.c:287:9
    #2 0x7c0b5f in ivas_jbm_dec_render /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/ivas_jbm_dec.c:1269:32
    #3 0x4ebfad in IVAS_DEC_GetRenderedSamples /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/lib_dec.c:1492:13
    #4 0x4ea6b0 in IVAS_DEC_GetSamples /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/lib_dec.c:1017:28
    #5 0x4f5873 in IVAS_DEC_VoIP_GetSamples /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/lib_dec.c:2812:28
    #6 0x4d7354 in decodeVoIP /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/apps/decoder.c:3284:24
    #7 0x4cf274 in main /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/apps/decoder.c:862:17
    #8 0x7fc7de37e082 in __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:308:16
    #9 0x41c59d in _start (/home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/CLANG2/IVAS_dec+0x41c59d)

Address 0x7ffc67526a40 is located in stack of thread T0 at offset 61472 in frame
    #0 0x5fab9f in ivas_osba_render_sf /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/ivas_osba_dec.c:259

  This frame has 2 object(s):
    [32, 61472) 'output_ism' (line 261) <== Memory access at offset 61472 overflows this variable
    [61728, 61856) 'p_output_ism' (line 262)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/gitlab-runner/builds/rZGLsUF2/0/rep/ivas-codec-pc/ivas-codec/lib_dec/ivas_ism_renderer.c:262:67 in ivas_ism_render_sf
Shadow bytes around the buggy address:
  0x10000ce9ccf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000ce9cd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000ce9cd10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000ce9cd20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000ce9cd30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10000ce9cd40: 00 00 00 00 00 00 00 00[f2]f2 f2 f2 f2 f2 f2 f2
  0x10000ce9cd50: f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2
  0x10000ce9cd60: f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
  0x10000ce9cd70: 00 00 00 00 00 00 00 00 f3 f3 f3 f3 00 00 00 00
  0x10000ce9cd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10000ce9cd90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==2631128==ABORTING

Link to test pipeline: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/jobs/224455

Ways to reproduce

dly_profile.dat

Using the scripts:

python3 scripts/IvasBuildAndRunChecks.py --checks CLANG2 -m OSBA_ISM3_PlanarHOA2_b256_fb_cbr -p /path/to/my/local/ci_linux_ltv_local.json -J dly_profile.dat

or directly:

make clean
make -j CLANG=2
./IVAS_cod -ism_sba 3 -2 ltvISM1.csv ltvISM2.csv ltvISM3.csv -max_band fb 256000 48 ltv48_OSBA_3ISM_HOA2.wav bit
networkSimulator_g192 dly_profile.dat bit bit_err trace_dump 1
./IVAS_dec -VOIP HOA3 48 bit_err out.wav