Thread (13 messages) 13 messages, 4 authors, 2021-06-21

Re: [PATCH 1/2] alpha/ptrace: Record and handle the absence of switch_stack

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2021-06-16 20:17:24
Also in: linux-arch, linux-m68k, lkml

Possibly related (same subject, not in this thread)

On Wed, Jun 16, 2021 at 01:31:52PM -0500, Eric W. Biederman wrote:
+.macro	SAVE_SWITCH_STACK
+	DO_SWITCH_STACK
+1:	ldl_l	$1, TI_FLAGS($8)
+	bis	$1, _TIF_ALLREGS_SAVED, $1
+	stl_c	$1, TI_FLAGS($8)
+	beq	$1, 2f
+.subsection 2
+2:	br	1b
+.previous
+.endm
What the hell?  *IF* you are going to go that way, at least put it into
->status, not ->flag - those are thread-synchronous and do not require that
kind of masturbation.
+.macro	RESTORE_SWITCH_STACK
+1:	ldl_l	$1, TI_FLAGS($8)
+	bic	$1, _TIF_ALLREGS_SAVED, $1
+	stl_c	$1, TI_FLAGS($8)
+	beq	$1, 2f
+.subsection 2
+2:	br	1b
+.previous
+	UNDO_SWITCH_STACK
+.endm
Ditto.  What do you need that flag for, anyway?
quoted hunk ↗ jump to hunk
@@ -117,7 +117,13 @@ get_reg_addr(struct task_struct * task, unsigned long regno)
 		zero = 0;
 		addr = &zero;
 	} else {
-		addr = task_stack_page(task) + regoff[regno];
+		int off = regoff[regno];
+		if (WARN_ON_ONCE((off < PT_REG(r0)) &&
+				!test_ti_thread_flag(task_thread_info(task),
+						     TIF_ALLREGS_SAVED)))
+			addr = &zero;
+		else
+			addr = task_stack_page(task) + off;
A sanity check in slow path, buggering the hell out of a fast path?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help