FAILED: patch "[PATCH] s390: always save and restore all registers on context switch" failed to apply to 4.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
fbbd7f1a51965b50dd12924841da0d478f3da71bMon Sep 17 00:00:00 2001
From: Heiko Carstens <[email protected]>
Date: Mon, 20 Nov 2017 12:38:44 +0100
Subject: [PATCH] s390: always save and restore all registers on context switch
The switch_to() macro has an optimization to avoid saving and restoring register contents that aren't needed for kernel threads.
There is however the possibility that a kernel thread execve's a user space program. In such a case the execve'd process can partially see the contents of the previous process, which shouldn't be allowed.
To avoid this, simply always save and restore register contents on context switch.
arch/s390/include/asm/switch_to.h +13 -14
@@ -30,21 +30,20 @@ static inline void restore_access_regs(unsigned int *acrs) asmvolatile ("lam 0,15,%0" : :"Q" (*(acrstype *)acrs)); } -#define switch_to (prev,next,last) do { \ - if (prev->mm) { \ - save_fpu_regs(); \ - save_access_regs(&prev->thread.acrs[0]); \ - save_ri_cb(prev->thread.ri_cb); \ - save_gs_cb(prev->thread.gs_cb); \ - } \ +#define switch_to (prev, next, last) do { \ +/* save_fpu_regs() sets the CIF_FPU flag, which enforces \ +* a restore of the floating point / vector registers as \ +* soon as the next task returns to user space \ +*/ \ +save_fpu_regs (); \ + save_access_regs(&prev->thread.acrs[0]); \ + save_ri_cb(prev->thread.ri_cb); \ + save_gs_cb(prev->thread.gs_cb); \update_cr_regs (next); \ - if (next->mm) { \ - set_cpu_flag(CIF_FPU); \ - restore_access_regs(&next->thread.acrs[0]); \ - restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ - restore_gs_cb(next->thread.gs_cb); \ - } \ - prev = __switch_to(prev,next); \ + restore_access_regs(&next->thread.acrs[0]); \ + restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ + restore_gs_cb(next->thread.gs_cb); \ + prev =__switch_to (prev, next); \ } while (0)#endif /* __ASM_SWITCH_TO_H */
Quoted 5 lines · On Mon, Dec 11, 2017 at 10:30:32PM +0100, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Please find below the patch applies against 4.4-stable.
Quoted 1 line
From
7ad104f73a7eece168875e2bc19d7c3f8944a938Mon Sep 17 00:00:00 2001
From: Heiko Carstens <[email protected]>
Date: Mon, 20 Nov 2017 12:38:44 +0100
Subject: [PATCH] s390: always save and restore all registers on context switch
commit fbbd7f1a51965b50dd12924841da0d478f3da71b upstream.
The switch_to() macro has an optimization to avoid saving and restoring register contents that aren't needed for kernel threads.
There is however the possibility that a kernel thread execve's a user space program. In such a case the execve'd process can partially see the contents of the previous process, which shouldn't be allowed.
To avoid this, simply always save and restore register contents on context switch.
--- arch/s390/include/asm/switch_to.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
arch/s390/include/asm/switch_to.h +9 -10
@@ -29,17 +29,16 @@ static inline void restore_access_regs(unsigned int *acrs) }#define switch_to (prev,next,last) do { \ - if (prev->mm) { \ - save_fpu_regs(); \ - save_access_regs(&prev->thread.acrs[0]); \ - save_ri_cb(prev->thread.ri_cb); \ - } \ +/* save_fpu_regs() sets the CIF_FPU flag, which enforces \ +* a restore of the floating point / vector registers as \ +* soon as the next task returns to user space \ +*/ \ +save_fpu_regs (); \ +save_access_regs (&prev->thread.acrs[0 ]); \ +save_ri_cb (prev->thread.ri_cb); \update_cr_regs (next); \ - if (next->mm) { \ - set_cpu_flag(CIF_FPU); \ - restore_access_regs(&next->thread.acrs[0]); \ - restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ - } \ +restore_access_regs (&next->thread.acrs[0 ]); \ +restore_ri_cb (next->thread.ri_cb, prev->thread.ri_cb); \ prev =__switch_to (prev,next); \ }while (0 )
Signature · 1 line
2.13.5
Quoted 8 lines · Heiko Carstens
Quoted 5 lines · On Mon, Dec 11, 2017 at 10:30:32PM +0100, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.Please find below the patch applies against 4.4-stable.
Applied, thanks.
greg k-h