Re: [RFC PATCH v1 22/25] unwind_user/eh_frame/x86: Handle DRAP expressions

From
sashiko-bot@kernel.org
Date
2026-08-18 15:10:49
Also in
linux-s390
Reply to
Jens Remus, 2026-08-18
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Inner DRAP frames fail to unwind due to `state->topmost` restriction on `UNWIND_USER_RULE_REG_OFFSET_DEREF`.
--
--- Patch [22]: [RFC PATCH v1 22/25] unwind_user/eh_frame/x86: Handle DRAP expressions ---
commit a2eefb14435ba994b91a768aaf44090977190c84
Author: Jens Remus [off-list ref]

unwind_user/eh_frame/x86: Handle DRAP expressions

GCC uses DRAP (Dynamic Realign Argument Pointer) when the stack needs
to be dynamically realigned. This patch adds x86-specific handling for
the CFA and FP DWARF expressions patterns used to describe how to unwind
through such frames.
quoted hunk ↗ jump to hunk
diff --git a/kernel/unwind/eh_frame.c b/kernel/unwind/eh_frame.c
index 19e2bc96ddbc2..49e8a3e8d794a 100644
--- a/kernel/unwind/eh_frame.c
+++ b/kernel/unwind/eh_frame.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1206,6 +1231,16 @@ static __always_inline int __find_frame_row(struct eh_frame_section *sec,
 		frame->fp.regnum = ctx.state.reg_regnum[FP_IDX];
 		frame->fp.offset = 0;
 		break;
+	case REG_REGISTER_OFFSET_DEREF:
+		if (ctx.state.reg_regnum[FP_IDX] > UINT_MAX)
+			return -EINVAL;
+		if (ctx.state.reg_offset[FP_IDX] < INT_MIN ||
+		    ctx.state.reg_offset[FP_IDX] > INT_MAX)
+			return -EOPNOTSUPP;
+		frame->fp.rule = UNWIND_USER_RULE_REG_OFFSET_DEREF;
[Severity: High]
Will this rule cause unwinding to fail for inner stack frames?

When an inner stack frame requires DRAP evaluation, the unwinder evaluates
UNWIND_USER_RULE_REG_OFFSET_DEREF in kernel/unwind/user.c:unwind_user_next_common()
like this:

	if (!state->topmost || unwind_user_get_reg(&fp, frame->fp.regnum))
		return -EINVAL;

Since inner frames are not topmost, this check will return -EINVAL and
abort the unwinding process. Could this truncate backtraces that pass
through dynamically realigned stack frames?
quoted hunk ↗ jump to hunk
+		frame->fp.regnum = ctx.state.reg_regnum[FP_IDX];
+		frame->fp.offset = ctx.state.reg_offset[FP_IDX];
+		break;
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818144954.2320378-1-jremus@linux.ibm.com?part=22
Thread (67 messages) 67 messages, 3 authors, last reply 2026-08-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help