Re: [PATCH] x86/entry/64: Fix CR3 restore order in paranoid_exit()

From: Ingo Molnar
Date: Wed Feb 14 2018 - 17:28:08 EST



* Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> Dave was right, my patch was obviously bogus. I couldn't figure out a
> real reproducer, so I made an artificial one (see below) and can confirm
> that your patch fixes it.
>
> I would resubmit the patch, but now you're the author, so I'm not sure
> how that works with the SOB.

I'd just have made you the author of the oneliner fix, in fair payment for writing
the changelog! ;-)

For anything larger and more complex we can do:

Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>

Which is technically an unusual but still correct 'SoB chain' describing the
true route of the patch.

See for example these scheduler commits:

8c0944cee7af: sched/deadline: Rename __dl_clear() to __dl_sub()
07f06cb3b5f6: sched: Start stopper early
7675104990ed: sched: Implement lockless wake-queues

In particular 7675104990ed is a good example:

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
[tweaks, adjustments, comments, etc.]
Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>

With his developer hat on PeterZ sent out a first implementation which Davidlohr
fixed, tested and signed off on - which PeterZ then applied with his maintainer
hat on, which Thomas acked and I committed to the scheduler git tree.

It would require two commits (one of which could easily be a bisection-breaker) to
express this in any other way.

But such chains are pretty rare and very much the exception: usually either the
original author takes care of everything, or the secondary author makes so many
changes that the secondary author becomes the primary author and the original
author is credited via a copyright notice and/or a tag like:

Originally-From: Ingo Molnar <mingo@xxxxxxxxxx>

> Feel free to add my
>
> Reported-and-tested-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

Thanks and added!

BTW:

> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -325,6 +325,8 @@ syscall_return_via_sysret:
> */
> SWITCH_TO_USER_CR3_STACK scratch_reg=%rdi
>
> + int3
> +
> popq %rdi
> popq %rsp
> USERGS_SYSRET64
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index 3d9b2308e7fa..74fabcdf6c36 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -605,6 +605,8 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
> goto exit;
> #endif
>
> + goto exit;

That's a very clever way to test such races!

Thanks,

Ingo