[Bug 14231] New: not_const_pp is causing memory reorder in clang without lto
bugzilla at busybox.net
bugzilla at busybox.net
Sat Sep 25 09:32:33 UTC 2021
https://bugs.busybox.net/show_bug.cgi?id=14231
Bug ID: 14231
Summary: not_const_pp is causing memory reorder in clang
without lto
Product: Busybox
Version: 1.33.x
Hardware: Other
OS: Other
Status: NEW
Severity: critical
Priority: P5
Component: Standard Compliance
Assignee: unassigned at busybox.net
Reporter: shana at zju.edu.cn
CC: busybox-cvs at busybox.net
Target Milestone: ---
In ash.c, there's `not_const_pp` which converts a const pointer to non-const
one. However, this will cause memory reorder and leads to SIGSEV.
Here's the instruction after compiled init_G from ash.c:
0x491624 <+32>: bl 0x4472d4 ; xzalloc at
xfuncs_printf.c:70
0x491628 <+36>: bl 0x49e070 ; OUTLINED_FUNCTION_1
0x49162c <+40>: mov w9, #-0x1
0x491630 <+44>: ldr x21, [x8]
0x491634 <+48>: str x0, [x8]
0x491638 <+52>: add x8, x21, #0x54 ; =0x54
-> 0x49163c <+56>: stp x8, x8, [x21, #0x20] ;<--- crash point
Here, x8 is the register that stores the addr of `ash_ptr_to_globals_misc`.
It's loaded first to x21 and then store from x0. And thus the reset instruction
crashed since x21 is 0 (addr of `ash_ptr_to_globals_misc` before assigned by
`xzalloc`).
I think the key problem is that in clang 9+, `not_const_pp` has a workaround
that breaks the memory dependency and thus the compiler reorders the memory.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list