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

Al Viro
2021-06-16T20:17:23Z

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?

> @@ -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?