> On May 14, 2020, at 9:03 AM, Mathieu Desnoyers
> <[email protected]> wrote:
>
> ----- On May 14, 2020, at 10:17 AM, Borislav Petkov [email protected] wrote:
>
>> + Tony.
>>
>>> On Tue, May 05, 2020 at 03:16:31PM +0200, Thomas Gleixner wrote:
>>> From: Peter Zijlstra <[email protected]>
>>>
>>> Convert #MC over to using task_work_add(); it will run the same code
>>> slightly later, on the return to user path of the same exception.
>>>
>>> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
>>> Signed-off-by: Thomas Gleixner <[email protected]>
>>> Reviewed-by: Frederic Weisbecker <[email protected]>
>>> ---
>>> arch/x86/kernel/cpu/mce/core.c | 56
>>> ++++++++++++++++++++++-------------------
>>> include/linux/sched.h | 6 ++++
>>> 2 files changed, 37 insertions(+), 25 deletions(-)
>>
>> I like this:
>>
>> Reviewed-by: Borislav Petkov <[email protected]>
>
> What I am not fully grasping here is whether this patch preserves the
> instruction
> pointer (and possibly other relevant information for siginfo_t) triggering the
> exception in a scenario where we have:
>
> - #MC triggered, queuing task work,
> - unrelated signal happens to be delivered to task,
> - exit to usermode loop handles do_signal first,
> - then it runs task work.
If anyone wants to ponder this, I suspect that we have lots of delightful bugs
in our handling of cr2, trapnr, and error_code in signals. We should move them
to the sigcontext, at least in kernel, and fix up ucontext when we deliver the
signal. The current code can’t possibly be correct.