-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[BOLT] Gadget scanner: detect non-protected indirect calls #131899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d82b35
9074fad
a1516bb
bbd4791
8865d1a
656e100
c9bc2c4
7324b6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,33 @@ class AArch64MCPlusBuilder : public MCPlusBuilder { | |
} | ||
} | ||
|
||
MCPhysReg | ||
getRegUsedAsCallDest(const MCInst &Inst, | ||
bool &IsAuthenticatedInternally) const override { | ||
Comment on lines
+281
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if this could be adapt so that it only needs to handle indirect calls? For example, at the moment, it seems the switch statement is not handling the newly introduced (in armv9.5) Compare and Branch instructions, see https://developer.arm.com/documentation/ddi0602/2024-09/Base-Instructions/CB-cc---register---Compare-registers-and-branch- My understanding is that only indirect calls need to be checked, not direct calls. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out! Non-indirect control flow instructions are inherently irrelevant here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened a separate PR #133227 on updating |
||
assert(isCall(Inst) || isBranch(Inst)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this assert could be made more strict now to only allow indirect calls and indirect branches? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd be more consistent with Sorry about the noise: GitHub showed this duplicated, so I tried to delete one, and then it deleted both. |
||
IsAuthenticatedInternally = false; | ||
|
||
switch (Inst.getOpcode()) { | ||
case AArch64::BR: | ||
case AArch64::BLR: | ||
return Inst.getOperand(0).getReg(); | ||
case AArch64::BRAA: | ||
case AArch64::BRAB: | ||
case AArch64::BRAAZ: | ||
case AArch64::BRABZ: | ||
case AArch64::BLRAA: | ||
case AArch64::BLRAB: | ||
case AArch64::BLRAAZ: | ||
case AArch64::BLRABZ: | ||
IsAuthenticatedInternally = true; | ||
return Inst.getOperand(0).getReg(); | ||
default: | ||
if (isIndirectCall(Inst) || isIndirectBranch(Inst)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As noted on another thread, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think either way is fine. Let's not block progress on discussing which order these PRs should land in. Please go with the order that makes most sense to you @atrosinenko . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, #133227 currently only corrects the implementation of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea is to update #133227 (which targets the Note that #133227 is targeted to |
||
llvm_unreachable("Unhandled indirect branch"); | ||
return getNoRegister(); | ||
} | ||
} | ||
|
||
bool isADRP(const MCInst &Inst) const override { | ||
return Inst.getOpcode() == AArch64::ADRP; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.