Re: [PATCH 02/24] objtool: Add retpoline validation

From: David Woodhouse
Date: Fri Jan 26 2018 - 04:55:19 EST


On Tue, 2018-01-23 at 16:25 +0100, Peter Zijlstra wrote:
>
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (insn->type != INSN_JUMP_DYNAMIC &&
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ insn->type != INSN_CALL_DYNAMIC) {
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂWARN_FUNC("retpoline_safe hint not a indirect jump/call",
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ insn->sec, insn->offset);
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -1;


...

ÂÂÂÂÂÂÂÂcase 0xff:
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (modrm_reg == 2 || modrm_reg == 3)

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*type = INSN_CALL_DYNAMIC;

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse if (modrm_reg == 4)

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*type = INSN_JUMP_DYNAMIC;

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse if (modrm_reg == 5)

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/* jmpf */
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*type = INSN_CONTEXT_SWITCH;


I *think* your check includes far calls (FF/3), although not far jumps?
It shouldn't, because I don't believe far calls are subject to the same
speculation?

Other than that, which you can probably ignore if you didn't have to
explicitly annotate [m]any safe far calls anyway,

Reviewed-by: David Woodhouse <dwmw@xxxxxxxxxxxx>

Thanks for doing this.

Attachment: smime.p7s
Description: S/MIME cryptographic signature