Skip to content

Commit

Permalink
Revert "[clang][slh] add attribute for speculative load hardening"
Browse files Browse the repository at this point in the history
until I figure out why the build is failing or timing out

***************************

Summary:
The prior diff had to be reverted because there were two tests
that failed. I updated the two tests in this diff

clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaCXX/attr-speculative-load-hardening.cpp

LLVM IR already has an attribute for speculative_load_hardening. Before
this commit, when a user passed the -mspeculative-load-hardening flag to
Clang, every function would have this attribute added to it. This Clang
attribute will allow users to opt into SLH on a function by function
basis.

This can be applied to functions and Objective C methods.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D54915

This reverts commit a5b3c23.
(r347617)

llvm-svn: 347628
  • Loading branch information
zbrid committed Nov 27, 2018
1 parent 5cec19d commit 0b35afd
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 109 deletions.
6 changes: 0 additions & 6 deletions clang/include/clang/Basic/Attr.td
Expand Up @@ -3091,9 +3091,3 @@ def AlwaysDestroy : InheritableAttr {
let Subjects = SubjectList<[Var]>;
let Documentation = [AlwaysDestroyDocs];
}

def SpeculativeLoadHardening : InheritableAttr {
let Spellings = [Clang<"speculative_load_hardening">];
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
let Documentation = [SpeculativeLoadHardeningDocs];
}
24 changes: 0 additions & 24 deletions clang/include/clang/Basic/AttrDocs.td
Expand Up @@ -3629,27 +3629,3 @@ GNU inline semantics are the default behavior with ``-std=gnu89``,
``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
}];
}

def SpeculativeLoadHardeningDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
This attribute can be applied to a function declaration in order to indicate
that `Speculative Load Hardening <https://llvm.org/docs/SpeculativeLoadHardening.html>`_
should be enabled for the function body. This can also be applied to a method
in Objective C.

Speculative Load Hardening is a best-effort mitigation against
information leak attacks that make use of control flow
miss-speculation - specifically miss-speculation of whether a branch
is taken or not. Typically vulnerabilities enabling such attacks are
classified as "Spectre variant #1". Notably, this does not attempt to
mitigate against miss-speculation of branch target, classified as
"Spectre variant #2" vulnerabilities.

When inlining, the attribute is sticky. Inlining a function that
carries this attribute will cause the caller to gain the
attribute. This is intended to provide a maximally conservative model
where the code in a function annotated with this attribute will always
(even after inlining) end up hardened.
}];
}
4 changes: 0 additions & 4 deletions clang/lib/CodeGen/CGCall.cpp
Expand Up @@ -1791,8 +1791,6 @@ void CodeGenModule::ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
if (CodeGenOpts.Backchain)
FuncAttrs.addAttribute("backchain");

// FIXME: The interaction of this attribute with the SLH command line flag
// has not been determined.
if (CodeGenOpts.SpeculativeLoadHardening)
FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
}
Expand Down Expand Up @@ -1856,8 +1854,6 @@ void CodeGenModule::ConstructAttributeList(
FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
if (TargetDecl->hasAttr<ConvergentAttr>())
FuncAttrs.addAttribute(llvm::Attribute::Convergent);
if (TargetDecl->hasAttr<SpeculativeLoadHardeningAttr>())
FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);

if (const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
AddAttributesFromFunctionProtoType(
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Sema/SemaDeclAttr.cpp
Expand Up @@ -6373,9 +6373,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case ParsedAttr::AT_Section:
handleSectionAttr(S, D, AL);
break;
case ParsedAttr::AT_SpeculativeLoadHardening:
handleSimpleAttribute<SpeculativeLoadHardeningAttr>(S, D, AL);
break;
case ParsedAttr::AT_CodeSeg:
handleCodeSegAttr(S, D, AL);
break;
Expand Down
18 changes: 0 additions & 18 deletions clang/test/CodeGen/attr-speculative-load-hardening.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions clang/test/CodeGen/attr-speculative-load-hardening.m

This file was deleted.

Expand Up @@ -2,7 +2,7 @@

// The number of supported attributes should never go down!

// CHECK: #pragma clang attribute supports 130 attributes:
// CHECK: #pragma clang attribute supports 129 attributes:
// CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
// CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
// CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
Expand Down Expand Up @@ -116,7 +116,6 @@
// CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
// CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
// CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
// CHECK-NEXT: SpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: SwiftContext (SubjectMatchRule_variable_is_parameter)
// CHECK-NEXT: SwiftErrorResult (SubjectMatchRule_variable_is_parameter)
// CHECK-NEXT: SwiftIndirectResult (SubjectMatchRule_variable_is_parameter)
Expand Down
34 changes: 0 additions & 34 deletions clang/test/SemaCXX/attr-speculative-load-hardening.cpp

This file was deleted.

22 changes: 13 additions & 9 deletions llvm/docs/LangRef.rst
Expand Up @@ -1643,15 +1643,19 @@ example:
``speculative_load_hardening``
This attribute indicates that
`Speculative Load Hardening <https://llvm.org/docs/SpeculativeLoadHardening.html>`_
should be enabled for the function body.

Speculative Load Hardening is a best-effort mitigation against
information leak attacks that make use of control flow
miss-speculation - specifically miss-speculation of whether a branch
is taken or not. Typically vulnerabilities enabling such attacks are
classified as "Spectre variant #1". Notably, this does not attempt to
mitigate against miss-speculation of branch target, classified as
"Spectre variant #2" vulnerabilities.
should be enabled for the function body. This is a best-effort attempt to
mitigate all known speculative execution information leak vulnerabilities
that are based on the fundamental principles of modern processors'
speculative execution. These vulnerabilities are classified as "Spectre
variant #1" vulnerabilities typically. Notably, this does not attempt to
mitigate any vulnerabilities where the speculative execution and/or
prediction devices of specific processors can be *completely* undermined
(such as "Branch Target Injection", a.k.a, "Spectre variant #2"). Instead,
this is a target-independent request to harden against the completely
generic risk posed by speculative execution to incorrectly load secret data,
making it available to some micro-architectural side-channel for information
leak. For a processor without any speculative execution or predictors, this
is expected to be a no-op.

When inlining, the attribute is sticky. Inlining a function that carries
this attribute will cause the caller to gain the attribute. This is intended
Expand Down

0 comments on commit 0b35afd

Please sign in to comment.