Re: [PATCH 13/24] objtool: Implement base jump_assert support
From: David Woodhouse
Date: Fri Jan 26 2018 - 05:45:43 EST
On Tue, 2018-01-23 at 16:25 +0100, Peter Zijlstra wrote:
> Implement a jump_label assertion that asserts that the code location
> is indeed only reachable through a static_branch. Because if GCC is
> absolutely retaded it could generate code like:
>
> ÂÂÂÂÂÂÂÂxor rax,rax
> ÂÂÂÂÂÂÂÂNOP/JMP 1f
> ÂÂÂÂÂÂÂÂmov $1, rax
> 1:
> ÂÂÂÂÂÂÂÂtest rax,rax
> ÂÂÂÂÂÂÂÂjz 2f
> ÂÂÂÂÂÂÂÂ
> 2:
>
> instead of the sensible:
>
> ÂÂÂÂÂÂÂÂNOP/JMP 1f
> ÂÂÂÂÂÂÂÂ
> 1:
>
> This implements objtool infrastructure for ensuring the code ends up
> sane, since we'll rely on that for correctness and security.
>
> We tag the instructions after the static branch with static_jump_dest=true;
> that is the instruction after the NOP and the instruction at the
> JMP+disp site.
>
> Then, when we read the .discard.jump_assert section, we assert that
> each entry points to an instruction that has static_jump_dest set.
>
> With this we can assert that the code emitted for the if statement
> ends up at the static jump location and nothing untowards happened.
>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Thank you for pandering to my paranoia. I suspect that misspelling the
word 'retarded' isn't going to be sufficient to stop people from
objecting to the use of that word, but other than that,
Reviewed-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature