Re: [RFC PATCH 3/4] x86/traps: Attempt to fixup exceptions in vDSO before signaling

From: Dave Hansen
Date: Thu Dec 06 2018 - 13:22:35 EST


On 12/5/18 3:20 PM, Sean Christopherson wrote:
> @@ -223,6 +224,10 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
> tsk->thread.error_code = error_code;
> tsk->thread.trap_nr = trapnr;
>
> + if (user_mode(regs) &&
> + fixup_vdso_exception(regs, trapnr, error_code, 0))
> + return 0;
> +
> return -1;
> }
>
> @@ -563,6 +568,9 @@ do_general_protection(struct pt_regs *regs, long error_code)
> tsk->thread.error_code = error_code;
> tsk->thread.trap_nr = X86_TRAP_GP;
>
> + if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0))
> + return;
> +
> show_signal(tsk, SIGSEGV, "", desc, regs, error_code);
>
> force_sig(SIGSEGV, tsk);
> @@ -854,6 +862,9 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
> if (!si_code)
> return;
>
> + if (fixup_vdso_exception(regs, trapnr, error_code, 0))
> + return;
> +
> force_sig_fault(SIGFPE, si_code,
> (void __user *)uprobe_get_trap_addr(regs), task);
> }
> --

Needs commenting, please.

But, also, this seems really ad-hoc. Probably, that's a result of our
signal generation being really ad-hoc itself. But, if this claims
"Attempt to fixup exceptions in vDSO before signaling", how do we assure
ourselves that we hit all the ad-hoc signal generation cases? How do we
know we didn't miss one or ten?

I want to hear more of the story of how you picked these sites and also
decided that this is a comprehensive-enough set of sites to patch.