Re: [PATCH 5.15 000/923] 5.15.3-rc3 review

From: Peter Zijlstra
Date: Thu Nov 18 2021 - 05:17:29 EST


On Thu, Nov 18, 2021 at 10:39:44AM +0100, Peter Zijlstra wrote:
> @@ -396,22 +416,27 @@ static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr
> static bool get_reg(struct unwind_state *state, unsigned int reg_off,
> unsigned long *val)
> {
> - unsigned int reg = reg_off/8;
> -
> if (!state->regs)
> return false;
>
> + pagefault_disable();
> if (state->full_regs) {
> - *val = READ_ONCE_NOCHECK(((unsigned long *)state->regs)[reg]);
> + __get_kernel_nofault(val, (void *)state->regs + reg_off, unsigned long, Efault);
> + pagefault_enable();
> return true;
> }
>
> if (state->prev_regs) {
> - *val = READ_ONCE_NOCHECK(((unsigned long *)state->prev_regs)[reg]);
> + __get_kernel_nofault(val, (void *)state->regs + reg_off, unsigned long, Efault);
^^^ prev_regs
> + pagefault_enable();
> return true;
> }
>
> return false;
> +
> +Efault:
> + pagefault_enable();
> + return false;
> }