crash-stack: Fix a misuse of register (workaround) 96/318296/3 accepted/tizen/unified/20250116.113515 accepted/tizen/unified/x/20250116.213650
authorSung-hun Kim <sfoon.kim@samsung.com>
Wed, 15 Jan 2025 07:00:36 +0000 (16:00 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Wed, 15 Jan 2025 07:23:20 +0000 (16:23 +0900)
commit4b49f35fb0efcb04774173cba516d59e4150fb18
tree3cf20f467c6d4251f41cefdf93f9acb9cacbab2f
parent35abbf0bc6a15a6fe7548500c9021020c7278a2a
crash-stack: Fix a misuse of register (workaround)

Regsiter values in struct user_regs_struct has a different layout against
its real register layout in the RISCV architecture. Especially, x0 in RISCV
means hard-wired zero register, but user_regs_struct has PC value as the
first member of it.

Since, crash-stack follows the layout of user_regs_struct, it should have
maps from original register numbers to its array indexes. The previous code
defines these maps, but there is a mistake. It does not properly map
UNW_RISCV_PC (64) to the index zero in its register value array. Because of
that, a try to get UNW_RISCV_PC causes a buffer-overflow problem.

This patch fixes this issue. But, I think that the use of register names
should be revised due to the their semantics.

Change-Id: I420da22f37e693e0bdf29debb03997d7cdd8bf29
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
src/crash-stack/crash-stack-riscv64.c