x86,rethook: Fix arch_rethook_trampoline() to generate a complete pt_regs
authorPeter Zijlstra <peterz@infradead.org>
Sat, 26 Mar 2022 02:27:28 +0000 (11:27 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 29 Mar 2022 02:38:51 +0000 (19:38 -0700)
commit0ef6f5c09371f17e142814e6996d6dfb8741925b
tree9a6b91596cc347a1438f4ce1db96200a5f2c1f08
parentf3a112c0c40dd96d53c8bdf3ea8d94d528f3b7b8
x86,rethook: Fix arch_rethook_trampoline() to generate a complete pt_regs

Currently arch_rethook_trampoline() generates an almost complete
pt_regs on-stack, everything except regs->ss that is, that currently
points to the fake return address, which is not a valid segment
descriptor.

Since interpretation of regs->[sb]p should be done in the context of
regs->ss, and we have code actually doing that (see
arch/x86/lib/insn-eval.c for instance), complete the job by also
pushing ss.

This ensures that anybody who does do look at regs->ss doesn't
mysteriously malfunction, avoiding much future pain.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/bpf/164826164851.2455864.17272661073069737350.stgit@devnote2
arch/x86/kernel/rethook.c