User Details
- User Since
- Mar 8 2020, 1:33 PM (185 w, 1 d)
Oct 7 2020
LGTM
LGTM.
Oct 6 2020
Update required by https://reviews.llvm.org/D88924.
Removed the Is64Bit parameter, which was redundant and unneeded.
Jul 30 2020
@craig.topper Yes.
Jul 27 2020
Addressed @craig.topper 's comments, and also changed some autos to Edge/Node wherever possible to improve readability.
Made one further optimization.
Jul 24 2020
Addressed @mattdr 's lone comment on style.
Addressed comments by @mattdr
Jul 23 2020
Jun 29 2020
LGTM.
Other than the inline comments, LGTM.
Jun 17 2020
That doesn't change my mind though because one could say the same wrt optimized LVI and SESES and just add that SESES has a more redundant LFENCEs than unoptimized LVI.
Jun 16 2020
@zbrid From a practical perspective I think you are correct. SESES mitigates a superset of gadgets that this pass mitigates, and therefore for code reuse/maintainability reasons it would make sense to replace this pass with SESES.
Jun 15 2020
Any progress on this patch? D75939 has been merged, but the SESES feature will not be secure until it has CFI protections.
Jun 9 2020
Addressed suggestion by @craig.topper to consolidate calls to emitInstruction().
Jun 5 2020
Jun 3 2020
@nikic I have posted https://reviews.llvm.org/D80964 as an alternative to this patch.
Jun 1 2020
I should add that I am submitting this patch as an alternative to D80064. That revision invisibly disables the mitigation at -O0, which may not be secure for some users.
May 26 2020
Changes have been merged.
May 16 2020
I can accept this change if the driver can also emit a warning when LVI hardening is enabled with -O0. We already have a similar warning when LVI CFI protections are enabled with retpoline. The warning is emitted in clang/lib/Driver/ToolChains/Arch/X86.cpp.
May 12 2020
May 7 2020
Addressed comments by @mattdr.
May 4 2020
Rebase onto master.
Rebase onto master.
Addressed the previously unaddressed comments, as pointed out by @craig.topper.
Apr 27 2020
Eliminated the NoFixedLoads feature in D75936, which simplified this patch quite a bit.
Addressed comments from @mattdr.
Removed the -x86-lvi-no-fixed CLI flag. This change simplifies the code flow quite a bit.
I don't think that this feature will be secure unless it is also used with -mlvi-cfi. Specifically, it is not sufficient to mitigate a RET simply by placing an LFENCE before it. There must also be a read from RSP's pointee just prior to that LFENCE. Also, indirect calls/jumps from memory must be decomposed into discrete load and call/jump from register operations with an interposed LFENCE. The -mlvi-cfi enables an X86 target feature that performs both of these mitigations correctly.
Apr 26 2020
Addressed comments from @craig.topper.
Apr 23 2020
Addressed comment by @craig.topper about the position of the CLI argument.
Previous diff had an error.
Added a CLI option to enable the inline asm hardening feature, which is now disabled by default. There is also a disclaimer in the CLI description that this feature is experimental.
@mattdr Thanks for the very scrupulous review!
Addressed feedback from @mattdr
Apr 16 2020
Apr 9 2020
There is now a more complete set of documentation for instructions that must be manually mitigated:
Apr 7 2020
@craig.topper Anyone else I should add as a reviewer? Or can we just go ahead and merge?
Summary points for @craig.topper who has commandeered this diff:
- fix the typo that Matt pointed out
- SizeT should not be a template parameter, and size_type should be fixed to int.
- Maybe have a member reference in MachineGadgetGraph to the associated MachineFunction.
- Determine how this pass (and other X86 machine passes) should fail on unsupported X86 subtargets.
Apr 6 2020
Apr 4 2020
Overall, the restyling by @craig.topper looks much better than what I had committed before. I agree that std::unique_ptr<T *> is the right "container" in this circumstance. And the addition of ArrayRef<> accessors is also a nice touch. A few extra inline comments.
Apr 3 2020
Apr 2 2020
Apr 1 2020
@craig.topper I think that removing spurious MBBs is not really necessary because the emitted machine code doesn't contain the spurious MBBs, from what I have observed. I added the check anyways, if only because others may look at this discrepancy and have the same question.
Mar 31 2020
4x agree.
Recommend the article here: https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
- What do you mean by allowing the compiler to devirtualize?
Suppose you have
struct Base { virtual void foo() = 0; }; struct D1 : Base { void foo() { … }; }; struct D2 final : Base { void foo() { … }; };
Added a comment to the header of X86IndirectThunks.cpp to indicate support for LVI thunks.
By the way, I had initially implemented this patch with a pure virtual base class and a retpoline thunk (and later LVI thunk) class that implements the interface. However, I could not for the life of me structure the classes in a manner that would allow the compiler to devirtualize. Using CRTP admittedly sacrifices some readability, but it does not prevent the compiler from inlining RetpolineThunkInserter's methods.
Updated to address @zbrid and @craig.topper 's comments.
Mar 25 2020
Due to performance/memory reasons, it is not a good idea to refactor this pass into a ModulePass.
Mar 24 2020
Mar 23 2020
Mar 19 2020
Mar 18 2020
One fix to correctly count the number of fences inserted.
Addressed Zola's comments.
Addressed Zola's comments.