x86,smap: Fix smap_{save,restore}() alternatives
authorPeter Zijlstra <peterz@infradead.org>
Tue, 28 Apr 2020 17:57:59 +0000 (19:57 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:30:51 +0000 (09:30 +0200)
commit91517e9518301fa5e661c91e152c148cbd3ff064
treebc82135c1659876fc6212f5ce3eaecb42dd8de07
parent6fc5d5834b372a70f28212c77847dea42cdc2713
x86,smap: Fix smap_{save,restore}() alternatives

[ Upstream commit 1ff865e343c2b59469d7e41d370a980a3f972c71 ]

As reported by objtool:

  lib/ubsan.o: warning: objtool: .altinstr_replacement+0x0: alternative modifies stack
  lib/ubsan.o: warning: objtool: .altinstr_replacement+0x7: alternative modifies stack

the smap_{save,restore}() alternatives violate (the newly enforced)
rule on stack invariance. That is, due to there only being a single
ORC table it must be valid to any alternative. These alternatives
violate this with the direct result that unwinds will not be correct
when it hits between the PUSH and POP instructions.

Rewrite the functions to only have a conditional jump.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200429101802.GI13592@hirez.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/include/asm/smap.h