Re: [RFC PATCH v1 08/16] unwind_user: Enable archs that save RA/FP in other registers

From
Josh Poimboeuf <jpoimboe@kernel.org>
Date
2025-07-18 04:51:44
Also in
bpf, lkml
Reply to
Jens Remus, 2025-07-17
On Thu, Jul 17, 2025 at 01:28:25PM +0200, Jens Remus wrote:
quoted
quoted
 	}
 
 	/* Get the Frame Pointer (FP) */
-	if (frame->fp_off && unwind_get_user_long(fp, cfa + frame->fp_off, state))
+	switch (frame->fp.loc) {
+	case UNWIND_USER_LOC_NONE:
+		break;
The UNWIND_USER_LOC_NONE behavior is different here compared to above.
See my comments below.
quoted
Do we also need UNWIND_USER_LOC_PT_REGS?
Sorry, I cannot follow.  Do you suggest to rename UNWIND_USER_LOC_REG to
UNWIND_USER_LOC_PT_REGS?
I think I completely misunderstood the meaning of UNWIND_USER_LOC_NONE.
Never mind :-)
quoted
quoted
+	case UNWIND_USER_LOC_STACK:
+		if (!frame->fp.frame_off)
+			goto done;
+		if (unwind_get_user_long(fp, cfa + frame->fp.frame_off, state))
+			goto done;
+		break;
+	case UNWIND_USER_LOC_REG:
+		if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_LOC_REG) || !topmost)
+			goto done;
The topmost checking is *really* getting cumbersome, I do hope we can
get rid of that.
Restoring from arbitrary registers is only valid in the topmost frame,
as their values (i.e. task_pt_regs(current)) are only available there.
For other frames only SP, FP, and RA register values are available.

I think this test makes sense.  Is this test really that expensive?
ra_off=0 (UNWIND_USER_LOC_NONE) on a !topmost frame should never happen
unless the sframe entry is bad.  But 0 is *far* from the only potential
bad RA offset value.  In the absolute worst case of a 4 byte offset,
there are 4+ billion other possible bad values that can still go
undetected.

So I question the usefulness of those !topmost tests.  And they do add
complexity to the code.

-- 
Josh
Thread (42 messages) 42 messages, 4 authors, last reply 2025-08-01
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