HomePhabricator

[X86] Automatically harden inline assembly RET instructions against Load Value…

Authored by craig.topper on Jun 13 2020, 3:16 PM.

Description

[X86] Automatically harden inline assembly RET instructions against Load Value Injection (LVI)

Previously, the X86AsmParser would issue a warning whenever a ret instruction is encountered. This patch changes the behavior to automatically transform each ret instruction in an inline assembly stream into:

shlq $0, (%rsp)
lfence
ret

which is secure, according to https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions.

Patch by Scott Constable with some minor changes by Craig Topper.