Adding a pass that replaces every ret instruction with the sequence:
pop <scratch-reg> lfence jmp *<scratch-reg>
where <scratch-reg> is some available scratch register, according to the
calling convention of the function being mitigated.
Differential D75935
Add RET-hardening Support to X86 to mitigate Load Value Injection (LVI) [3/6] sconstab on Mar 10 2020, 10:00 AM. Authored by
Details Adding a pass that replaces every ret instruction with the sequence: pop <scratch-reg> lfence jmp *<scratch-reg> where <scratch-reg> is some available scratch register, according to the
Diff Detail
Event TimelineComment Actions Can you use the "Edit Related Revisions" link to set the parent/child relationships of these patches and put "[1/5]" in the titles? Comment Actions In the case where there is no scratch register available, changed from using OR 0 to SHL 0 to load/store from/to RSP. The benefit of SHL 0 is that it does not clobber EFLAGS.
Comment Actions Thanks! Looks great. Please wait for another LGTM from someone more versed in LLVM conventions, but LGTM.
|
I think this should be at the top of the function.