Skip to content

Segmentation fault in function mjs_stack_size (at mjs.c:7849) #304

@Vancir

Description

@Vancir

I found a segmentation fault bug while mjs (latest, b1b6eac) executes the PoC on Ubuntu 20.04.

Download the PoC: mjs_segv_mjs7849.zip

ASAN Report

==866928==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000d8 (pc 0x0000004dd2e8 bp 0x7ffdde783148 sp 0x7ffdde783148 T0)
==866928==The signal is caused by a READ memory access.
==866928==Hint: address points to the zero page.
    #0 0x4dd2e8 in mjs_stack_size /data/song/projects/latest-programs/mjs/BUILD/mjs.c:7849:13
    #1 0x4dd040 in vptr /data/song/projects/latest-programs/mjs/BUILD/mjs.c:7853:14
    #2 0x4dd317 in mjs_getretvalpos /data/song/projects/latest-programs/mjs/BUILD/mjs.c:7810:21
    #3 0x4dd441 in mjs_return /data/song/projects/latest-programs/mjs/BUILD/mjs.c:7837:13
    #4 0x4db66c in mjs_ffi_cb_free /data/song/projects/latest-programs/mjs/BUILD/mjs.c:10140:3
    #5 0x4dd8ee in mjs_exec_internal /data/song/projects/latest-programs/mjs/BUILD/mjs.c:9044:5
    #6 0x4ddaeb in mjs_exec_file /data/song/projects/latest-programs/mjs/BUILD/mjs.c:9067:11
    #7 0x4e1df7 in main /data/song/projects/latest-programs/mjs/BUILD/mjs.c:11406:13
    #8 0x7f236f6dfd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #9 0x7f236f6dfe3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #10 0x41f344 in _start (/data/song/projects/latest-programs/mjs/mjs-bin+0x41f344)

Steps to reproduce

git clone https://github.com/cesanta/mjs.git
cd mjs
clang -g -O1 -fsanitize=address -fno-omit-frame-pointer -Wno-error -DMJS_MAIN mjs.c -dl -o mjs_asan
./mjs_asan -f PoC 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions